]> granicus.if.org Git - python/commitdiff
Backport of 52811:
authorNeal Norwitz <nnorwitz@gmail.com>
Tue, 21 Nov 2006 05:29:34 +0000 (05:29 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Tue, 21 Nov 2006 05:29:34 +0000 (05:29 +0000)
Bug #1599782: Fix segfault on bsddb.db.DB().type().

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.

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 28543f6f7553966da0cd582d0e4c723fc308a992..231004dc4ae082cd571a782eefd460773a97e229 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -276,6 +276,8 @@ Library
 Extension Modules
 -----------------
 
+- Bug #1599782: fix segfault on bsddb.db.DB().type().
+
 - Fix bugs in ctypes:
   - anonymous structure fields that have a bit-width specified did not work
   - cast function did not accept c_char_p or c_wchar_p instances as first arg
index 9d56e2765d4786beb7f3c9c4d195040eb0f0f50c..8e343a652e9b3c65cb7201b501889d942bfa8ce3 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);