[Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.28,
1.28.6.1
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Wed Nov 12 20:17:57 EST 2003
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv22584/Lib/test
Modified Files:
Tag: release23-maint
test_weakref.py
Log Message:
Backport of fix for SF bug 840829, memory corruption in some cases of
weakref callbacks.
This is a critical bugfix. It's already been fixed on the trunk (2.4
development). I don't intend to backport it to the 22 line, but if a
2.2.4 ever gets released, this should be in it.
Index: test_weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v
retrieving revision 1.28
retrieving revision 1.28.6.1
diff -C2 -d -r1.28 -r1.28.6.1
*** test_weakref.py 14 Jul 2003 21:37:17 -0000 1.28
--- test_weakref.py 13 Nov 2003 01:17:55 -0000 1.28.6.1
***************
*** 299,302 ****
--- 299,322 ----
self.fail("exception not properly restored")
+ def test_sf_bug_840829(self):
+ # "weakref callbacks and gc corrupt memory"
+ # subtype_dealloc erroneously exposed a new-style instance
+ # already in the process of getting deallocated to gc,
+ # causing double-deallocation if the instance had a weakref
+ # callback that triggered gc.
+ # If the bug exists, there probably won't be an obvious symptom
+ # in a release build. In a debug build, a segfault will occur
+ # when the second attempt to remove the instance from the "list
+ # of all objects" occurs.
+
+ import gc
+
+ class C(object):
+ pass
+
+ c = C()
+ wr = weakref.ref(c, lambda ignore: gc.collect())
+ del c
+
class Object:
More information about the Python-checkins
mailing list