[plt-scheme] scheme_check_threads gives Bus error on OS X
At Sun, 06 Nov 2005 00:27:11 -0500, Jon Rafkind wrote:
> 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.
The bus error results from MzScheme trying to call
scheme_wakeup_on_input(), but your application doesn't set it. I'll
change MzScheme to make setting scheme_wakeup_on_input optional, and
you can avoid the problem meanwhile by setting scheme_wakeup_on_input
to a function that does nothing.
On the other hand, if you're not setting scheme_wakeup_on_input and
instead relying on busy-waiting, you probably just want
scheme_thread_block(0.0) to let other threads run.
With either implementation, beware that calling the Cocoa API from
other MzScheme threads probably won't work. MzScheme thread swapping is
implemented by copying and overwriting the C stack. This means that if
any other MzScheme thread calls into the Cocoa API, Cocoa may notice
that the stack isn't consistent with the active event loop.
Matthew