I had some chance to play around with this and got a little further, but not much...<div><br></div><div>I added a hack in my code to do this as per the example file mentioned below...</div><div><br></div><div><div>;;;(use-foreign-library opengl)</div>
<div>(eval-when (:compile-toplevel :load-toplevel :execute)</div><div> (let* ((s (ccl:make-semaphore)))</div><div> (ccl:process-interrupt ccl::*initial-process*</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (lambda ()</div>
<div> (ccl:open-shared-library "OpenGL.framework/OpenGL")</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (ccl:open-shared-library "GLUT.framework/GLUT")</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (ccl:signal-semaphore s)))</div><div> (ccl:wait-on-semaphore s))</div><div><br></div><div>With this code, the shared libraries appear to load, but I do get the error message:</div>
<div><br></div><div><div>kevin-mac-pro-3:lisp kevinsmith$ ccl64</div><div>; loading system definition from /Users/kevinsmith/ccl-lisp/babel/babel.asd into #<Package "ASDF0"></div><div>; registering #<SYSTEM BABEL> as BABEL</div>
<div>; loading system definition from /Users/kevinsmith/ccl-lisp/alexandria/alexandria.asd into #<Package "ASDF0"></div><div>; registering #<SYSTEM :ALEXANDRIA> as ALEXANDRIA</div><div>; loading system definition from /Users/kevinsmith/ccl-lisp/trivial-features/trivial-features.asd into #<Package "ASDF0"></div>
<div>; registering #<SYSTEM TRIVIAL-FEATURES> as TRIVIAL-FEATURES</div><div>Welcome to Clozure Common Lisp Version 1.5-dev-r13523M-trunk (DarwinX8664)!</div><div>? (require :cl-opengl)</div><div>; Warning: Don't know how to setup a hook before saving cores on this Lisp.</div>
<div>; While executing: #<Anonymous Function #x302000D3A5DF>, in process listener(1).</div><div>:CL-OPENGL</div><div>NIL</div><div>? </div></div><div><br></div><div>I created a stripped down version of my program that just has the cl-opengl and GLUT libraries in it and it looks like the first window comes up, but then it hangs before GL gets a chance to clear the window and do its thing... Is the warning (the hook) the problem ?</div>
<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote">On Sun, Aug 1, 2010 at 8:02 PM, Gary Byers <span dir="ltr"><<a href="mailto:gb@clozure.com">gb@clozure.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Apple decided to enforce the restriction that some shared libraries (I don't<br>
remember which one(s)) only be initialized on the initial thread of the OS-level<br>
process by executing a breakpoint instruction. (It's the World's Most Advanced<br>
Operating System!) That breakpoint causes the process to terminate with the<br>
message you're seeing when the library in question is loaded (directly or as<br>
the result of loading some library which depends on it) from a CCL listener<br>
thread (or a SLIME REPL thread, or ... any thread other than the initial<br>
one.)<br>
<br>
The general workaround is to replace:<br>
<br>
(open-shared-library "culprit.dylib")<br>
<br>
with<br>
<br>
(run-in-initial-thread-and-wait-until-done<br>
(lambda () (open-shared-library "culprit.dylib")))<br>
<br>
There are a few issues:<br>
<br>
1) The affected code may be in a third-party lisp library; it'd be good if<br>
the authors of such libraries made the necessary changes so that people<br>
didn't keep running into this.<br>
<br>
2) It can be hard to know which libraries are affected. I think that the<br>
actual check-and-breakpoint is in the initialization code for the<br>
CoreFoundation library; whether that's correct or not, it's in some<br>
library that's used by many other things on OSX, so the rule of thumb<br>
is something like "when in doubt, force library loading to happen on<br>
the initial thread in OSX."<br>
<br>
3) There are several ways to do what I'm calling<br>
RUN-IN-INITIAL-THREAD-AND-WAIT-UNTIL-DONE; I don't think that we yet<br>
offer a standard way of doing this (though CCL::CALL-IN-INITIAL-PROCESS<br>
us present in recent versions of the trunk and is intended to become<br>
an exported/documented/standard interface in the near future.)<br>
<br>
We changed some of our examples when this "check and breakpoint" behavior<br>
was introduced (in 10.6, IIRC); see "ccl:examples;opengl-ffi.lisp", for<br>
instance.<br>
<br>
4) I'd want to think about this more than I have, but at the moment I can't<br>
think of a reason for OPEN-SHARED-LIBRARY not to at least default to<br>
doing what it does on the initial thread by default.<div><div></div><div class="h5"><br>
<br>
<br>
<br>
On Sun, 1 Aug 2010, Kevin Smith wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The only hurdle for me for trying out (and maybe switching) to clozure on the mac platform is that I can't seem to get the<br>
cl-opengl package loaded. I get the error: "Trace/BPT trap" when I try to load that package. (All other dependent packages<br>
like cffi, loaded successfully).<br>
I am using ccl64, version 1.5 on Darwin/MAC OS (DarwinX8664). Latest version of cl-opengl.<br>
<br>
I believe I also tried it on the 32-bit ccl. Same problem. It looks like it only compiles a few source files in the<br>
cl-opengl package before it dies.<br>
<br>
If someone can point out to me how I can trace this to provide more information on where it is crashing or maybe someone has<br>
run across this already with this particular package.<br>
<br>
Thanks,<br>
Kevin<br>
<br>
<br>
</blockquote>
</div></div></blockquote></div><br></div>