]> granicus.if.org Git - python/commitdiff
Bug #1599782: Fix segfault on bsddb.db.DB().type().
authorNeal Norwitz <nnorwitz@gmail.com>
Tue, 21 Nov 2006 05:26:22 +0000 (05:26 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Tue, 21 Nov 2006 05:26:22 +0000 (05:26 +0000)
The problem is that _DB_get_type() can't be called without the GIL
because it calls a bunch of PyErr_* APIs when an error occurs.
There were no other cases in this file that it was called without the GIL.
Removing the BEGIN/END THREAD around _DB_get_type() made everything work.

Will backport.

Lib/bsddb/test/test_dbobj.py
Misc/NEWS
Modules/_bsddb.c

index 6799fc9c220a80c72123d025ad4f5e824dd9e343..af494e19fd937c29893e414823e8fcd6cf1fc6c1 100644 (file)
@@ -69,6 +69,10 @@ class dbobjTestCase(unittest.TestCase):
         self.db.close()
         self.env.close()
 
+    def test03_dbobj_type_before_open(self):
+       # Ensure this doesn't cause a segfault.
+       self.assertRaises(db.DBInvalidArgError, db.DB().type)
+
 #----------------------------------------------------------------------
 
 def test_suite():
index 0e2969ea5113b02748c29178a484d2ed26ce121c..d58cce51460ccac1c418b8cf207d663a35547fea 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -242,6 +242,8 @@ Extension Modules
   a2b_qp() function, instead leave it in the string as quopri.decode()
   does.
 
+- Bug #1599782: Fix segfault on bsddb.db.DB().type().
+
 - Bug #1567666: Emulate GetFileAttributesExA for Win95.
 
 - Patch #1576166: Support os.utime for directories on Windows NT+.
index 9be5c6aa429232b9d8764175eb23e23b84bc4461..e6046e723109dbfed349422358dcc4ea9731be5a 100644 (file)
@@ -1779,9 +1779,7 @@ DB_get_type(DBObject* self, PyObject* args)
         return NULL;
     CHECK_DB_NOT_CLOSED(self);
 
-    MYDB_BEGIN_ALLOW_THREADS;
     type = _DB_get_type(self);
-    MYDB_END_ALLOW_THREADS;
     if (type == -1)
         return NULL;
     return PyInt_FromLong(type);