Ticket #1710 (new bug)

Opened 12 years ago

Last modified 12 years ago

[BUG] exit of a Coroutine affects all of its sister clones

Reported by: pmichaud Owned by:
Priority: normal Milestone:
Component: none Version: 2.5.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

If any clone of a Coroutine dies, then it exits all of the clones. The best way to illustrate is with code:

$ cat coro.pir 
.sub 'main' :main
    .const 'Sub' $P99 = 'coro'

    .local pmc three, four, five
    three = clone $P99
    four  = clone $P99
    five  = clone $P99

    three(3)
    four(4)
    five(5)

    three()
    four()
    five()

    three()
.end

.sub '' :anon :subid('coro')
    .param int x
    print x
    say '.0'
    .yield (x)

    print x
    say '.1'
    .yield (x)

    print x
    say '.done'
.end
$ ./parrot coro.pir 
3.0
4.0
5.0
3.1
4.1
5.1
3.done
4.done
5.done
Cannot resume dead coroutine.
current instr.: 'main' pc 37 (coro.pir:11)
$ 

Note that calling the 'three' clone the final time is sufficient to make the 'four' and 'five' clones to also resume + exit (without being explicitly invoked), and leads to the "Cannot resume dead coroutine" exception.

This is very likely to be strongly related to TT #1702.

One possible workaround is to make sure that a coroutine never exits; e.g., by entering an infinite "yield" loop at the end of the Coroutine. This is what PGE has apparently done for quite some time.

Pm

Change History

Changed 12 years ago by NotFound

See also TT #1003

Note: See TracTickets for help on using tickets.