On Mon, May 03, 2004 at 10:46:28AM -0400, Dan Sugalski wrote:

> 3) The embedding wrapper is responsible for setting and resetting the 
> top of stack.

I don't think that this is quite right. The embedding wrapper needs to
set (and reset) the top of stack only if it's not set.

Otherwise this scenario could happen:

Eternal Program
    |
    +-> Embedding wrapper (sets stack top)
            |
            +-> More parrot code with something unanchored on stack *
                    |
                    +-> Call back out to a subroutine in the external program
                            |
                            +-> Embedding wrapper (sets stack top)
                                    |
                                    +-> More parrot code that triggers GC
                                            |
                                            +-> GC


And the GC routine won't spot that pointer on the stack at *


If the embedding wrapper (well wrappers onto the data access functions and
onto the runloop) both set a stack top if it's not yet set, and clear it on
exit if they set it, then I think that parrot won't fall foul of the above.

Effectively the embedder is playing by the same rules as Leo said that we
have to have for a nested call to the runloop - anything calling the runloop
must ensure that all PMCs are anchored.

Nicholas Clark

Reply via email to