[Pyobjc-dev] Bug fix in exception bridging code
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2002-10-17 14:37:51
|
The whole exercise with figuring out how to use gdb w/my app (that is composed of multiple frameworks that are dynaloaded) was to track down a bug in bridge. Specifically, the bridge was crashing if I tried to invoke a selector on an Python subclass of an ObjC object where neither the ObjC or Python subclass implemented the method (I'm in the middle of porting code from ObjC to Python [and not just as a mental exercise] and haven't finished implementing all methods) -- the classic forward:: / does not recognize selector situation. According to the documentation, the PyErr_Fetch() function can return NULL for the exc_value and exc_traceback arguments. This appears to be exactly what is happening -- see the gdb session below -- in that exc_traceback is NULL. Calling Py_DECREF() with a NULL pointer causes a bus error / bad access error. Patched. Fixed. Committed. Ronald: Is it correct? :-) Program received signal EXC_BAD_ACCESS, Could not access memory. 0x004168c8 in ObjCErr_ToObjC () at Modules/objc/objc_util.m:222 222 Py_DECREF(exc_traceback); (gdb) l 217 userInfo:userInfo]; 218 219 Py_DECREF(repr); 220 Py_DECREF(exc_type); 221 Py_DECREF(exc_value); 222 Py_DECREF(exc_traceback); 223 224 [val raise]; 225 } 226 Current language: auto; currently objective-c (gdb) bt #0 0x004168c8 in ObjCErr_ToObjC () at Modules/objc/objc_util.m:222 #1 0x0041caf0 in object_method_methodSignatureForSelector (self=0x1ee6d50, selector=0x907e2470, aSelector=0xdd32bc) at Modules/objc/class-builder.m:869 #2 0x90935664 in -[NSObject(NSForwardInvocation) forward::] () #3 0x907ac130 in _objc_msgForward () #4 0x00dcf8d4 in -[ViewTableDataSource issueUrlButtonAction:] (self=0x6c8b80, _cmd=0xdd2bf8, sender=0xe60b20) at Intent-Application/ViewTableDataSource.m:468 #5 0x9426fe2c in -[NSApplication sendAction:to:from:] () #6 0x942fbff0 in -[NSControl sendAction:to:] () #7 0x942b3a38 in -[NSCell _sendActionFrom:] () #8 0x942b3fc4 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:] () #9 0x9429ef78 in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] () #10 0x944763b0 in -[NSTableView mouseDown:] () #11 0x9450dfd4 in -[NSWindow sendEvent:] () #12 0x9426e328 in -[NSApplication sendEvent:] () #13 0x9426a524 in -[NSApplication run] () #14 0x94272598 in NSApplicationMain () #15 0x00c23f40 in objc_NSApplicationMain (self=0x229d2c0, args=0x907c85c8, kwds=0x0) at Modules/Cocoa/_AppKit.m:80 #16 0x00045930 in PyObject_Call () #17 0x0005df64 in PyEval_GetFuncDesc () #18 0x0005b1f8 in PyEval_EvalCode () #19 0x0005c634 in PyEval_EvalCodeEx () #20 0x00058a80 in PyEval_EvalCode () #21 0x00027e90 in PyRun_FileExFlags () #22 0x00026ef4 in PyRun_SimpleFileExFlags () #23 0x000069f0 in Py_Main () #24 0x00002970 in start () #25 0x000027f0 in start () (gdb) p exc_traceback $1 = (PyObject *) 0x0 (gdb) (gdb) p exc_value $2 = (PyObject *) 0x1ec6fe0 |