[Vm-dev] Event-driven Cog still crashing (more observations)

David T. Lewis lewis at mail.msen.com
Tue Jul 19 11:26:03 UTC 2011

On Tue, Jul 19, 2011 at 12:22:42AM -0400, Dimitry Golubovsky wrote:
> Hi,
> Looks like I found the reason why longjmp crashes subsequent GC:
> StackEvtInterpreter >> initStackPagesAndInterpret
> --------------------------------------------------------------
> 	theStackMemory := self
> 						cCode: 'alloca(stackPagesBytes)'
> 						inSmalltalk:
> 							[stackPages := self stackPagesClass new.
> 							 stackPages initializeWithByteSize: stackPagesBytes for: self].
> --------------------------------------------------------------
> Of course longjmp discards this allocation. Next time the interpreter
> is entered, this stack space will be overwritten. Hence the bizarre
> effects.
> I haven't tried to work around this; just wandering whether using
> malloc instead of alloca is in any way harmful...

If you use malloc(), then you would also need to call free(), which
might be tricky given that you are longjmp'ing over the situation.

Note that alloca is used in various places in the interpreter and
in plugins, both in the slang and in support code for the various

I have not looked at any of the code, but in your earlier message
you described your use of longjmp, based on Andreas' earlier work,
as follows:

1. Set a jmp_buf to to hold the jump target at the start of the
interpret() function
2. longjmp to this jmp_buf in the transferTo function if its argument
is 0 (thus exiting the interpreter once no processes are ready to

I wonder if there is some other approach that you could use to
accomplish this? 


More information about the Vm-dev mailing list