Pavlo Korzhyk
2008-08-10 09:18:27 UTC
# New Ticket Created by "Pavlo Korzhyk"
# Please include the string: [perl #57764]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57764 >
To reproduce simply copy-paste example 9 from docs/art/ppp02-pmc.pod
and run it:
======================================================
.include "timer.pasm" # for the timer constants
.sub expired
print "Timer has expired!\n"
.end
.sub _ :main
$P0 = new 'Timer'
$P1 = global "expired"
$P0[.PARROT_TIMER_HANDLER] = $P1 # call sub in $P1 when timer goes off
$P0[.PARROT_TIMER_SEC] = 2 # trigger every 2 seconds
$P0[.PARROT_TIMER_REPEAT] = -1 # repeat indefinitely
$P0[.PARROT_TIMER_RUNNING] = 1 # start timer immediately
global "timer" = $P0 # keep the timer around
$I0 = 0
loop:
print $I0
print ": running...\n"
inc $I0
sleep 1 # wait a second
goto loop
.end
======================================================
The output under Ubuntu is:
(0.6.4 on Ubuntu and WinXP, 0.6.3 on Ubuntu produce the similar bad result)
======================================================
0: running...
1: running...
maximum recursion depth exceeded
current instr.: 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
... repeated approx 2000 times ...
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub '_' pc 41 (timertest.pir:22)
Segmentation fault
======================================================
If "-1"(indefinitely) is replaced with "5" - you'll get 6 messages
"Timer has expired!"
all at once:
======================================================
0: running...
1: running...
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
2: running...
3: running...
4: running...
5: running...
(pressed Ctrl+C here)
======================================================
For N repeats you will get N+1 executions of the handler.
# Please include the string: [perl #57764]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57764 >
To reproduce simply copy-paste example 9 from docs/art/ppp02-pmc.pod
and run it:
======================================================
.include "timer.pasm" # for the timer constants
.sub expired
print "Timer has expired!\n"
.end
.sub _ :main
$P0 = new 'Timer'
$P1 = global "expired"
$P0[.PARROT_TIMER_HANDLER] = $P1 # call sub in $P1 when timer goes off
$P0[.PARROT_TIMER_SEC] = 2 # trigger every 2 seconds
$P0[.PARROT_TIMER_REPEAT] = -1 # repeat indefinitely
$P0[.PARROT_TIMER_RUNNING] = 1 # start timer immediately
global "timer" = $P0 # keep the timer around
$I0 = 0
loop:
print $I0
print ": running...\n"
inc $I0
sleep 1 # wait a second
goto loop
.end
======================================================
The output under Ubuntu is:
(0.6.4 on Ubuntu and WinXP, 0.6.3 on Ubuntu produce the similar bad result)
======================================================
0: running...
1: running...
maximum recursion depth exceeded
current instr.: 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
... repeated approx 2000 times ...
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub '_' pc 41 (timertest.pir:22)
Segmentation fault
======================================================
If "-1"(indefinitely) is replaced with "5" - you'll get 6 messages
"Timer has expired!"
all at once:
======================================================
0: running...
1: running...
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
2: running...
3: running...
4: running...
5: running...
(pressed Ctrl+C here)
======================================================
For N repeats you will get N+1 executions of the handler.