mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
SF bug 840829: weakref callbacks and gc corrupt memory.
subtype_dealloc(): This left the dying object exposed to gc, so that if cyclic gc triggered during the weakref callback, gc tried to delete the dying object a second time. That's a disaster. subtype_dealloc() had a (I hope!) unique problem here, as every normal dealloc routine untracks the object (from gc) before fiddling with weakrefs etc. But subtype_dealloc has obscure technical reasons for re-registering the dying object with gc (already explained in a large comment block at the bottom of the function). The fix amounts to simply refraining from reregistering the dying object with gc until after the weakref callback (if any) has been called. This is a critical bug (hard to predict, and causes seemingly random memory corruption when it occurs). I'll backport it to 2.3 later.
This commit is contained in:
parent
045f1de57e
commit
add09b4149
3 changed files with 32 additions and 1 deletions
|
@ -12,6 +12,12 @@ What's New in Python 2.4 alpha 1?
|
|||
Core and builtins
|
||||
-----------------
|
||||
|
||||
- Critical bugfix, for SF bug 840829: if cyclic garbage collection
|
||||
happened to occur during a weakref callback for a new-style class
|
||||
instance, subtle memory corruption was the result (in a release build;
|
||||
in a debug build, a segfault occurred reliably very soon after).
|
||||
This has been repaired.
|
||||
|
||||
- Added a reversed() builtin function that returns a reverse iterator
|
||||
over a sequence.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue