[Zodb-checkins] CVS: Zope/lib/python/BTrees/tests -
testConflict.py:1.16.6.1
Tim Peters
tim.one at comcast.net
Thu Apr 29 17:51:52 EDT 2004
Update of /cvs-repository/Zope/lib/python/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv30552/lib/python/BTrees/tests
Modified Files:
Tag: Zope-2_7-branch
testConflict.py
Log Message:
http://collector.zope.org/Zope/553 "sporadic Zope crashes"
BTree bucket conflict resolution could segfault if fed three empty
buckets. Fixed, and a new test added that *will* segfault if you
don't recompile Zope's C code.
=== Zope/lib/python/BTrees/tests/testConflict.py 1.16 => 1.16.6.1 ===
--- Zope/lib/python/BTrees/tests/testConflict.py:1.16 Thu Apr 24 11:31:42 2003
+++ Zope/lib/python/BTrees/tests/testConflict.py Thu Apr 29 17:51:50 2004
@@ -659,6 +659,36 @@
# And the resulting BTree shouldn't have internal damage.
b._check()
+
+ # The snaky control flow in _bucket__p_resolveConflict ended up trying
+ # to decref a NULL pointer if conflict resolution was fed 3 empty
+ # buckets. http://collector.zope.org/Zope/553
+ def testThreeEmptyBucketsNoSegfault(self):
+ self.openDB()
+
+ r1 = self.db.open().root()
+ self.assertEqual(len(self.t), 0)
+ r1["t"] = b = self.t # an empty tree
+ get_transaction().commit()
+
+ r2 = self.db.open().root()
+ copy = r2["t"]
+ # Make sure all of copy is loaded.
+ list(copy.values())
+
+ # In one transaction, add and delete a key.
+ b[2] = 2
+ del b[2]
+ get_transaction().commit()
+
+ # In the other transaction, also add and delete a key.
+ b = copy
+ b[1] = 1
+ del b[1]
+ # If the commit() segfaults, the C code is still wrong for this case.
+ self.assertRaises(ConflictError, get_transaction().commit)
+ get_transaction().abort()
+
def test_suite():
suite = TestSuite()
for k in (TestIOBTrees, TestOOBTrees, TestOIBTrees, TestIIBTrees,
More information about the Zodb-checkins
mailing list