[Top][All Lists]

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

Re: Guile and ucontext

From: Neil Jerram
Subject: Re: Guile and ucontext
Date: Sat, 23 May 2009 16:30:05 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Fredrik Tolf <address@hidden> writes:

> Well, unless I have grossly misunderstood what I read in threads.[ch],
> Guile records the base and top of the stack per POSIX thread, and
> doesn't ever change the base unless it is found at a higher address than
> before.


> Thus, to take an example:
> Say that I first run a function in Guile mode when the stack pointer is
> somewhere in the ELF-loader allocated stack; say at 0xBEEFBABE. Guile
> records that address as the stack base. Then I switch to some
> heap-allocated stack and run some Guile code. Now, my stack pointer
> might be at, say, 0x0F00FACE.

Ah, I see, so the stack base is changing for the same thread.  That is
something that never happens in Guile at the moment, even when playing
with continuations.  So we're into new territory here.

> The previously recorded base address won't
> change, but that stack will be used as the top of the stack. When the
> Guile's GC runs, it would, then, try to mark all words from the stack
> top to the stack base: that is, from 0x0F00FACE to 0xBEEFBABE.
> Almost the entire process space, in other words (and probably with lots
> of unmapped space in it).
> I hope that makes my point clearer.

Yes, it's clear now, thanks for explaining.

In principle maybe all that is needed to handle this is to

- update the affected thread's stack base when the context is

- save off the top and bottom of the previous stack (if it may be
  reinstated again later), so that the GC can scan it - this would be
  similar to how a continuation's stack is stored in the continuation
  object and scanned by the GC.

I hope that helps.  Do you plan to have a go at these changes?


reply via email to

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