[Top][All Lists]

[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 01:24:57 -0500

> From: Michele Bini <address@hidden>
> I have been encountering some problems (segfaults) while testing
> call/cc driven coroutines in guile.  While coroutines are probably not
> a commonly found programming paradigm nowadays, i wonder if this is
> the symptom of some deeper problem regarding continuation support in
> guile.

They seem to be very popular these last six hours!

> After a few seconds executing these loops, guile segfaults with no
> explicit error message.  Apparently there is some memory leak or
> stack allocation problem going on (scm seems to share the same
> problem, by the way).
> ;; simpler test, triggering the same problem
> (define (coroutines-test2)
>   (define x call-with-current-continuation)
>   (define w write)
>   (define (a y)
>     (define l (list 1 2 3 4 5))
>     (let loop ()
>       (for-each (lambda (a) (w a) (set! y (x y))) l)
>       (loop)))
>   (let loop ((a a)) (loop (x a))))

I do not get a segfault (Guile 1.5.4).  I get execution starting off
fairly quickly but getting slower and slower with long pauses and
sucking up all compute cycles until I kill it, which is not easy
because bash starts to take half a minute to echo a character.

I blame the OS (obsolete Linux version) for not giving bash a
decent time slice.  An error message when you run out of storage
would be a good thing.  This program does segfault after a few

   (define (test) (let loop ((x '())) (loop (cons x x))))

I don't really understand your program.  Why do you think it
is not essentially equivalent to this one?  It seems to be
creating continuations at a furious rate and doing
the same as mine, only with stack frames instead of cons cells.

     -- Keith Wright  <address@hidden>

Programmer in Chief, Free Computer Shop <>
         ---  Food, Shelter, Source code.  ---

reply via email to

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