[Openmcl-devel] fragile GUI Programming: Unhandled exception 10

Alexander Repenning ralex at cs.colorado.edu
Thu Oct 29 23:16:56 PDT 2009


Debugging in CCL has improved a lot but unfortunately there is still a  
very frequent case when building GUIs which essentially reduces the  
process of CCL programming to roughly the same level as C++ or Java,  
i.e., programming problem -> stack trace -> spinning beach ball

When raising just about any kind of condition in the "initial" thread  
the AltConsole will come up with some handy exploration features  
including a simple backtrace. So far so good. But then when trying to  
exit the break loop one gets

Unhandled exception 10 at 0x9137eaa7, context->regs at #xbffff2bc

No options left at this point. Spinning beach ball, force quit

It would be OK if this would be a rare case but in a Cocoa app MOST  
code is running the initial thread (e.g., menu functions, view, window  
call backs) which means that one is always dangerously close to a  
complete application crash even for simple problems as, say, calling a  
missing function. This really should not be the case with Lisp.

To reproduce (just tested with CCL 1.4):

;; resizable window with red fill
(in-package :ccl)


(defclass crasher-view (ns:ns-view)
   ()
   (:metaclass ns:+ns-object))

;;this works
(objc:defmethod (#/drawRect: :void) ((self crasher-view)  
(rect :<NSR>ect))
   (ccl::with-autorelease-pool
       (#/set (#/redColor ns:ns-color))
     (#_NSRectFill (#/bounds self))))



(ns:with-ns-rect (frame 100 100 200 200)
   (let* ((w (make-instance 'ns:ns-window
               :with-content-rect frame
               :style-mask (logior #$NSTitledWindowMask # 
$NSClosableWindowMask #$NSResizableWindowMask)
               :backing #$NSBackingStoreBuffered
               :defer #$YES))
          (view (make-instance 'crasher-view :with-frame (#/frame (#/ 
contentView w)))))
     (#/setContentView: w view)
     (#/orderFront: w nil)
     w))

;; redefine with buggy version, resize window to cause problem
(objc:defmethod (#/drawRect: :void) ((self crasher-view)  
(rect :<NSR>ect))
   (ccl::with-autorelease-pool
       (#/set (#/redColor ns:ns-color))
     (#_NSRectFill (#/bounds self))
     ;; call function that does not exist
     (missing-function 22)))


in AltConsole you get:

 > Error: Undefined function CCL::MISSING-FUNCTION called with  
arguments (22) .
 > While executing: (:INTERNAL CCL::|-[CrasherView drawRect:]|), in  
process Initial(0).
 > Type :GO to continue, :POP to abort, :R for a list of available  
restarts.
 > If continued: Retry applying CCL::MISSING-FUNCTION to (22).
 > Type :? for other options.
1 > :pop
Unhandled exception 10 at 0x9137eaa7, context->regs at #xbffff2bc
Exception occurred while executing foreign code
  at __removeHandler2 + 199
? for help
[46133] Clozure CL kernel debugger:


What are the options at this point? Is there a way to pop back from  
the problem, i.e., abort the event processing without a crash? One  
could wrap all the call back code up with some error handlers but then  
one does not get a backtrace to find the real problem which can be  
tricky in the case of some complex call back function calling all kind  
of other functions.

What is this exception "Unhandled exception 10 at 0x9137eaa7, context- 
 >regs at #xbffff2bc" ?

Any suggestions are appreciated,  Alex





Prof. Alexander Repenning

University of Colorado
Computer Science Department
Boulder, CO 80309-430

vCard: http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf

Openmcl-devel Devel <openmcl-devel at clozure.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20091030/2203dabb/attachment.htm>


More information about the Openmcl-devel mailing list