Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

coroutine segfaults

8 views
Skip to first unread message

Klaas-Jan Stol

unread,
May 30, 2006, 3:57:51 PM5/30/06
to Perl6 Internals
hi,

I was investigating a possible implementation of the "reset" method for
coroutine.pmc, but I encountered the following:
if the coroutine is called more times than the coroutine ".yield()s", it
segfaults

example:

.sub main :main
.local int result
.local pmc cor
cor = global "_foo"

result = cor()
print result # prints 1
print "\n"

result = cor()
print result # prints 2
print "\n"

result = cor()
print result # prints 3
print "\n"

result = cor()
print result # prints 4
print "\n"

result = cor()
print result #prints 5
print "\n"

result = cor()
print result # what should this do? start over again?
print "\n"
end
.end

.sub _foo
.yield(1)
.yield(2)
.yield(3)
.yield(4)
.yield(5)
#.yield(6)
.end

If the last .yield() is uncommented, it works, but otherwise, the last
result (5, in this case), is printed twice. Can this be a bug?

regards,
klaas-jan

Leopold Toetsch

unread,
May 30, 2006, 4:58:57 PM5/30/06
to Klaas-Jan Stol, Perl6 Internals

On May 30, 2006, at 21:57, Klaas-Jan Stol wrote:

> I was investigating a possible implementation of the "reset" method
> for coroutine.pmc, but I encountered the following:
> if the coroutine is called more times than the coroutine ".yield()s",
> it segfaults

Yep. That's very much related to the proposed .reset() method.
Currently a coroutine shouldn't fall off through .return() as this case
is just not implemented. A reasonable approach to handle that is IMHO
to do a reset for that case, which would need some adapations in
RetContinuation.invoke to check, if a Coro was left.

leo

0 new messages