[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about coroutines

From: Marius Vollmer
Subject: Re: about coroutines
Date: 07 Dec 2001 01:30:50 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Marius Vollmer <address@hidden> writes:

> Do you think this is a bug on Guile's part, or is it unavoidable?  I
> plan to find the precise location where the continuation references
> stick...

Ok, here is what I've found.

It's a real conservative GC bug, and it's impossible to fix (without
going to a precise GC or non-copying continuations) since it is all
over the place.  The continuations stick in a stack slot that is not
associated with any variable, it's just debris from a previous
function call (specifically, from building the lexical environment of

The continuations also stick in the environment itself, which they
don't need to, and in this particular program also in the throw_value
slot of the continuation objects themselves, which they don't need to

The last two bugs can easily be fixed, but this wont fix the larger
problem since the continuations also stick in inaccessible locations.

We can't easily drop the conservative GC in favour of a precise one,
or the stack-copying continuations, I think, but we should do
something about this nevertheless.

What I think would be a good solution would be to offer one-shot
continuations that can only be invoked once.  That way, we could
deallocate the continuation stack once it has been copied back, and
stale references in it would not confuse the GC.  An adhoc
implementation is just running the original coroutines-test in
constant space.

We could even avoid copying the stack in the first place, when the
continuation is invoked before its creating call/cc returns.

One-shot continuations should make for a nice SRFI, actually.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]