[plt-scheme] embedded MzScheme not started on main thread

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Aug 1 19:31:46 EDT 2002

> I'm having a problem trying to embed 
> MzScheme 103 into a Java application on 
> Windows NT4-SP6.  It sees to work fine 
> when I initialize MzScheme from the main 
> app thread. If I initialize MzScheme from 
> an alternate thread,  it crashes while 
> executing Scheme code.  It doesn't always 
> crash in the same place in the Scheme code 
> which makes me think that the GC may be 
> involved.  In both environments,  I 
> statically link MzScheme into my 
> application and set the 
> GC_use_registered_statics flag since Java 
> starts multiple threads.  Both 
> environments also link with an MzScheme 
> library and GC built with the WIN32
> _THREADS define flag set.  

I think you're right that it has something to do with GC, and with
finding the stack base. You might try setting GC_stackbottom (I may
have the variable name wrong) to an address that represents the base of
the stack --- usually the address of a procedure-local variable.

But if upgrading to v200 is possible, I recommend that first. Merely
upgrading is unlikely to make the problem disappear, but the interface
is cleaner for setting the stack base and registering globals, and I'm
more confident that it works. In v200, call scheme_set_stack_base() to
achieve the effect of setting GC_stackbottom and


Posted on the users mailing list.