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

From: Scott Walters (scott at integra-online.com)
Date: Wed Jul 31 13:32:31 EDT 2002

Hi,

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.  

In the environment that works, my 
application is an executable that 
initializes MzScheme on the main 
application thread.  It then creates a 
Java VM and starts the Java application 
which creates a thread pool for request 
processing. As these requests are 
processed, they call back into the 
executable which then invokes MzScheme 
code.  Since the requests are processed on 
an alternate thread, the Scheme invocation 
calls are routed back to the main 
application thread for processing.

In the environment that doesn't work, the 
application is built as a Windows DLL 
instead of an application.  The Java 
application is started from a Java command 
line and eventually executes Java code on 
one of it's threads that loads my DLL.  
Calls made from Java into the DLL end up 
invoking the same Scheme code that works 
in the other environment but crashes in 
this environment after 2 or 3 other 
successful Scheme invocations.

I saw a news post (link below) which 
indicates that Scheme may have trouble in 
this type of situation.  Does anyone have 
any more info on this or a suggestion on 
how I can fix it?

Thanks,
Scott Walters

http://www.cs.utah.edu/plt/mailarch/plt-
scheme-2000/msg00836.html





Posted on the users mailing list.