Message101580
The tp_dealloc of a type can chose to resurrect an object. the subtype_dealloc() in typeobject.c does this when it calls the tp_del() member and it has increased the refcount.
The problem is, that if you subclass a custom C object, and that C object's tp_dealloc() chooses to resurrect a dying object, that doesn't go well with subtype_dealloc().
After calling basedealloc() (line 1002 in typeobject.c), the object's type is decrefed. But if the object was resurrected by basedealloc() this shouldn't have been done. The object will be alive, but the type will be missing a reference. This will cause a crash later.
This could be fixable if we knew somehow after calling basedealloc() if the object were still alive. But we cannot check "self" because it may have died.
The only way out of this conundrum that I can see is to change the signature of tp_dealloc() to return a flag, whether it did actually delete the object or not.
Of course, I see no easy way around not clearing the slots, but the clearing of the dict could be postponed until after the call to basedealloc().
Since tp_dealloc _can_ resurrect objects (subtype_dealloc does it), subclassing such objects should work, and not crash the interpreter if the base class' dp_dealloc() decides to do so.
No suggested |
|
Date |
User |
Action |
Args |
2010-03-23 13:28:33 | kristjan.jonsson | set | recipients:
+ kristjan.jonsson |
2010-03-23 13:28:32 | kristjan.jonsson | set | messageid: <1269350912.78.0.210466349131.issue8212@psf.upfronthosting.co.za> |
2010-03-23 13:28:30 | kristjan.jonsson | link | issue8212 messages |
2010-03-23 13:28:29 | kristjan.jonsson | create | |
|