[issue3100] weakref subclass segfault

Adam Olsen report at bugs.python.org
Fri Jun 13 07:14:52 CEST 2008


Adam Olsen <rhamph at gmail.com> added the comment:

1. MyRef is released from the module as part of shutdown
2. MyRef's subtype_dealloc DECREFs its dictptr (not clearing it, as
MyRef is dead and should be unreachable)
3. the dict DECREFs the Dummy (MyRef's target)
4. Dummy's subtype_dealloc calls PyObject_ClearWeakRefs to notify of its
demise
5. the callback is called, with the dead MyRef as an argument
6. If MyRef's dict is accessed a segfault occurs.  Presumably just
calling the callback does enough damage to explain the segfault without
accessing MyRef's dict.

As I understand, a deleted weakref doesn't call its callback.  However,
subtype_dealloc doesn't call the base type's tp_dealloc until *after* it
does everything else.  Does it need a special case for weakrefs, or
maybe a tp_predealloc slot?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3100>
_______________________________________


More information about the Python-bugs-list mailing list