On 21-dec-2005, at 2:51, Bob Ippolito wrote:
>> Trying to figure why the following test app crashes when a 'testtest'
>> Apple event is sent to it:
>>
>> ------------------------------------------------------------
>> # cocoatest.py
>>
>> from PyObjCTools import AppHelper
>> from Carbon.AE import AEInstallEventHandler
>>
>> AEInstallEventHandler('test', 'test', lambda evt, res:0)
>>
>> AppHelper.runEventLoop()
>>
>> ------------------------------------------------------------
>>
>> Additional notes: the test app doesn't crash when
>> AppKit.NSAppleEventManager is used to install the event handler
>> function,
>> nor when CarbonEvt is used instead of PyObjC.
>>
>> I'm getting a similar crash in some CarbonX.OSA code within a
>> PyObjC-based
>> app and reckon identifying what's causing the test app to crash
>> will help
>> me solve the problem there. Any ideas as to the cause, suggestions
>> where
>> to look, how to debug it more effectively, etc. would be a big
>> help as
>> I've been stuck on this for more than a day now and have only just
>> fitted
>> a new laptop case after the last temper tantrum. :p
>
> My guess is that there's a refcount or GIL bug in
> Carbon.AE.AEInstallEventHandler.
You guessed correctly: AEInstallEventHandler is blissfully unaware of
refcounts. It simply passes the address of the callback function
object to the C AEInstallEventHandler, and hopes the object still
exists when the callback comes.
The workaround is to keep a reference to the object around. Which is
apparently also the normal case, I think this is the first report
I've seen of this problem, and I wouldn't be surprised if this code
even predates my responsibility for the toolbox modules (i.e. Guido
himself wrote this:-).
--
Jack Jansen, <[EMAIL PROTECTED]>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma
Goldman
_______________________________________________
Pythonmac-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig