guile-user
[Top][All Lists]
Advanced

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

Re: about coroutines


From: Keith Wright
Subject: Re: about coroutines
Date: Sun, 18 Nov 2001 15:30:12 -0500

> From: Michele Bini <address@hidden>
> CC: address@hidden
> 
> >>>>> "Keith" == Keith Wright <address@hidden> writes:
> 
>   Keith> I do not get a segfault (Guile 1.5.4).  I get execution
>   Keith> starting off fairly quickly but getting slower and slower
>   Keith> with long pauses and sucking up all compute cycles until I
>   Keith> kill it, which is not easy because bash starts to take half a
>   Keith> minute to echo a character.
> 
> Well, this is not what seems to happen under other scheme
> implementations, MIT Scheme is able to run these loops indefinitely
> without increasing in memory usage, so i assume that there is
> something wrong with guile and scm (also my scheme-scheme interpreter
> runs this fine; although, well, i don't claim my implementation to be
> perfect).

This answers the question I forgot to ask.  It looks like we have two
distinct bugs here then.

   *bug1 - segfault without error message on stack (heap?) overflow.
   *bug2 - obscure memory leak in certain uses of call/cc

>   Keith> (define (test) (let loop ((x '())) (loop (cons x x))))
> 
> Yep this one makes guile crash much faster, even here :).

So that's a demo of bug1.


>   Keith> I don't really understand your program.
> 
> Well, the main difference is that my test program is not supposed to
> allocate memory that the garbage collector can not free,

That's the part I didn't understand, and still don't, but if other
implementations can do it, that give a good reason to think that it
should be done.

> and the continuations it creates should get garbage collected once
> they are no more referenced.

As I understand it, Guile implements continuations by copying the
stack into the heap.  But it uses "conservative" garbage collection,
which operates without knowing what is on the stack.  It just saves
anything that looks like it might be a pointer.  This (allegedly)
works well enough, because nothing stays too long on the stack
anyway, but I wonder if the argument remains valid when you start
copying stack bits into the heap.  Maybe your memory layout just
happens to be such that GC algorithm is catastrophically conservative.
This would explain why it doesn't segfault for me (at least within
the time I am willing to wait).

-- 
     -- Keith Wright  <address@hidden>

Programmer in Chief, Free Computer Shop <http://www.free-comp-shop.com>
         ---  Food, Shelter, Source code.  ---



reply via email to

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