[plt-scheme] scheme_check_threads gives Bus error on OS X

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Sun Nov 6 00:27:11 EST 2005

While trying to use a C library with MzScheme I have found 
scheme_check_threads as a way to run MzScheme while inside the Cocoa 
NSApplication main event loop. Calling scheme_check_threads results in a 
Bus error, however. The setup involved is irrelevant, I think, as I have 
reduced the problem to a simple example. This is with MzScheme 299.400 
built from source.

(define os-x-function (ffi-thing "os_x_function"))

(begin
   (printf "Starting\n")
   (thread (lambda ()
                    (let loop ()
                       (printf "printing\n")
                       (sleep 1)
                       loop)))
   (os-x-function))

void os_x_function(){
        printf( "File: %s Line: %s\n", __FILE__, __LINE__ );
        scheme_check_threads();
        printf( "File: %s Line: %s\n", __FILE__, __LINE__ );
}

And the output I see is:
$ mzscheme -f x.ss
Starting
File: foo.c Line: 23
Bus error

The Bus error occurs after about a second. In truth there is more code 
in my program but I think I can safely ignore it as it pertains to this 
problem. I read the docs about including pthread in with the C library 
and Im fairly sure Im not doing this, so assuming Im not is there some 
other obvious thing Im doing wrong?


Posted on the users mailing list.