[Openmcl-devel] YAWC (Yet Another Weird Crash)

Raffael Cavallaro raffaelcavallaro at mac.com
Thu May 28 16:07:01 PDT 2009

On May 28, 2009, at 5:52 PM, Ron Garret wrote:

>  I've already checked the
> obvious things like the reference counts on the PDF files dropping to
> zero and everything seems OK.

I don't see the effect you're seeing - I've tried several times  
already. However, I notice you're doing gui things without ensuring  
they happen on the main thread. Could this be it? Apple want you to  
use performSelectorOnMainThread:withObject:yadaYadaYada & co.

FWIW, I use this for all calls that frob GUI entities - it  
accomplishes the same thing, but unlike the above Cocoa call, it isn't  
limited to a single parameter:

(in-package :ccl)

(defmacro gui-do (&body body)
   (let ((values-list (gensym "GUI-DO-VALUES-LIST"))
         (sem (gensym "GUI-DO-SEMAPHORE")))
     `(if (eq *current-process* ccl::*initial-process*)
        (progn , at body)
        (let* ((,sem (make-semaphore))
               (,values-list nil))
           (lambda ()
             (setq ,values-list (multiple-value-list (progn , at body)))
             (signal-semaphore ,sem)))
          (wait-on-semaphore ,sem)
          (values-list ,values-list)))))

I also have another version which doesn't wait for the return value(s)  
if you're interested.

So calls to things like #/setContentView: I would wrap thus: (gui-do  
(#/setContentView: ... etc. just to ensure they happen on the main  

Hopefully the Clozure crew will let me know if this is really  


Raffael Cavallaro
raffaelcavallaro at me.com

More information about the Openmcl-devel mailing list