Here is a small code fragment that will reproduce the problem. Must be run MAC OSX, version 10.6+ with sbcl compiled with threads (or use macports version with +threads option when compiling):

* (sb-thread:make-thread (lambda () (sb-alien:load-shared-object "/System/Library/Frameworks/OpenGL.framework/OpenGL")))

rlwrap: warning: sbcl killed by SIGTRAP.
rlwrap has not crashed, but for transparency,
it will now kill itself with the same signal

Trace/BPT trap

On Sun, Aug 15, 2010 at 3:19 AM, Nikodemus Siivola <> wrote:
On 11 August 2010 18:03, Kevin Smith <> wrote:

> Sorry if I asked this already, but is there any way to insure foreign
> libraries are loaded on the initial thread for sbcl built with threads ?
> There is a problem with certain MAC OSX libraries (in 10.6, snow leopard)
> in this regard (like OpenGL, for example).  They can only be loaded in
> initial thread or cause breakpoint exceptions otherwise. Maybe sbcl already
> takes care of this ?

No, unfortunately there isn't a convenient mechanism to automatically
do this for all foreign libraries.

Options available:

* If an application, just take care to load all foreign code in the
initial thread.

* If a library, document the need to be loaded in the initial thread.
(And make sure you're not doing any lazy loading!)

That said, there is one option that you _could_ use, but which is
really bad and I STRONGLY recommend against it. Grab a reference to
the initial thread and use INTERRUPT-THREAD to call LOAD-SHARED-OBJECT
there. Don't do this, really.

Apropos, can you post a snippet of code that shows how to provoke the error?


 -- Nikodemus