[Python-Dev] subtype_dealloc needs rethinking
tim.one at comcast.net
Thu Nov 13 15:17:53 EST 2003
> There are two identifiable (so far) problems in subtype_dealloc
Make that one; I'm convinced the first is bogus.
> 1. A weakref callback can resurrect self, but the code isn't aware of
> that now.
I no longer believe that's possible. While a weakref callback can resurrect
objects in dead cycles, a weakref callback called *as a result* of anything
subtype_dealloc does cannot resurrect the object subtype_dealloc is tearing
down (because self's refcount is legitimately 0 then -- Python code can't
get to self, even if it was in a dead cycle, and the weakref callback
doesn't pass the dying object to the callback either).
That just leaves subtype_dealloc with its problem of allowing gc to believe
that self is collectible. I'm feeling more confident about that too after
staring at the code more, but a complete fix remains strained.
More information about the Python-Dev