[Pyobjc-dev] [ pyobjc-Bugs-735815 ] ivar leak & crash
Brought to you by:
ronaldoussoren
From: SourceForge.net <no...@so...> - 2003-05-10 20:34:55
|
Bugs item #735815, was opened at 2003-05-10 22:34 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=114534&aid=735815&group_id=14534 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Just van Rossum (jvr) Assigned to: Nobody/Anonymous (nobody) Summary: ivar leak & crash Initial Comment: There is problem with assigning Python objects (that are not derived from NSObject) to ivars: >>> from objc import ivar >>> from Foundation import NSObject >>> class Foo(NSObject): ... x = ivar("x") ... >>> class Doo(object): ... def __del__(self): ... print "deleting Doo instance %x" % id(self) ... >>> f = Foo.alloc().init() >>> f.y = Doo() # assinging to non-ivar >>> f.y = 12 deleting Doo instance 47bd10 >>> f.x = Doo() # assigning to ivar >>> f.x = 12 # look, no delete message >>> f.x = Doo() >>> del f.x Bus error Two problems: 1) when *replacing* an ivar, the referenced object leaks 2) when *deleting* an ivar, there's a crash (btw. the bus error also occurs if you try to delete an ivar that's not yet set (nil). (Note that the leak does _not_ seem to occur when the referenced object's class is derived from NSObject, but the del crash occurs indepent of the type of the object.) However, we have a bigger problem: ivars/outlets that are set by Cocoa during nib-awakening-time are weak references (not retained), so we can't simply release an ivar when we overwrite it with something else. Likewise during dealloc: currently ivars are _not_ released, which causes leaks for those ivars that are set from Python (x.y = z implies a retain for z). Except perhaps for the Bus Error (which smells like a different problem altogether), these things are not easily fixed. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=114534&aid=735815&group_id=14534 |