[plt-scheme] bus error on exit
Hi,
I've embedded mzscheme, and my main program calls exit() from a non-
scheme thread, which leads to a bus error in
'scheme_do_close_managed' in thread.c. Is there a recommended way to
shutdown the embedded mzscheme in this situation?
thanks,
Rob
----
// Minimal code to reproduce exit crash
#define MZ_PRECISE_GC 1
#include <scheme.h>
#include <pthread.h>
static void *scheme_thread_main(void *ignored);
static void start_mzscheme();
int main(int argc, char **argv)
{
start_mzscheme();
printf("sleep\n");
sleep(3);
printf("exit\n");
exit(0);
}
static void start_mzscheme()
{
int r;
pthread_t t;
r = pthread_create(&t, NULL, scheme_thread_main, NULL);
if (r)
{
printf("Couldn't start pthread for scheme\n");
exit(-1);
}
}
static void *scheme_thread_main(void *ignored)
{
Scheme_Env *env = NULL;
Scheme_Object *name = NULL;
MZ_GC_DECL_REG(2);
MZ_GC_VAR_IN_REG(0, env);
MZ_GC_VAR_IN_REG(1, name);
# ifdef MZ_PRECISE_GC
# define STACK_BASE &__gc_var_stack__
# else
# define STACK_BASE NULL
# endif
scheme_set_stack_base(STACK_BASE, 1);
MZ_GC_REG();
env = scheme_basic_env();
// scheme_load("embed.scm");
MZ_GC_UNREG();
return NULL;
}