[plt-scheme] MzScheme + SDL threads

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Apr 27 12:43:44 EDT 2005

At Tue, 26 Apr 2005 07:45:51 -0700, Barry Tolnas wrote:
> [...] When I tried writing a 
> simple test shown below to put scheme in its own SDL thread (which is a 
> pthread underneath)  scheme_basic_env() crashes. A stack trace is shown 
> after the code listing. It seems there is an infinite recursion in calls 
> to GC_clear_stack_inner. [...]
>
> int DoScheme(void *args)
> {
>   Scheme_Env* e;
> 
>   printf("Scheme thread starting\n");
> 
>   scheme_set_stack_base(NULL, 1); /* required for OS X, only */

My guess is that the GC can't find the stack base, and so you'll have
to help it by supplying a non-NULL pointer for the first argument of
scheme_set_stack_base, something like this:

 int DoScheme(void *args) {
   int dummy;
   scheme_set_stack_base(&dummy, 1);
   return Really_DoScheme(args);
 }

 int Really_DoScheme(void *args)
 {
   Scheme_Env* e;

   printf("Scheme thread starting\n");

   e = scheme_basic_env();
   scheme_eval_string("(display \"hello world\n\")", e);

   fprintf(stdout,"Scheme Thread finished\n");
   fflush(stdout);
   return 0;
 }


I'm guessing because I'm never sure how well Boehm's conservative GC
can actually find the stack and static variables. With PLT-implemented
GCs, we always punt and require the program to supply that information,
like above.

Matthew



Posted on the users mailing list.