summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-11-21 05:26:22 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-11-21 05:26:22 (GMT)
commit4fe442383d140dbdee28102f8854a7db14370bcb (patch)
tree89b6ae7462517d8fa35a06bd2adb7094a8f28a3e
parent5dba6f74c60391d2933830f82f3fa8ee0a5d241c (diff)
downloadcpython-4fe442383d140dbdee28102f8854a7db14370bcb.zip
cpython-4fe442383d140dbdee28102f8854a7db14370bcb.tar.gz
cpython-4fe442383d140dbdee28102f8854a7db14370bcb.tar.bz2
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. Will backport.
-rw-r--r--Lib/bsddb/test/test_dbobj.py4
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_bsddb.c2
3 files changed, 6 insertions, 2 deletions
diff --git a/Lib/bsddb/test/test_dbobj.py b/Lib/bsddb/test/test_dbobj.py
index 6799fc9..af494e1 100644
--- a/Lib/bsddb/test/test_dbobj.py
+++ b/Lib/bsddb/test/test_dbobj.py
@@ -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():
diff --git a/Misc/NEWS b/Misc/NEWS
index 0e2969e..d58cce5 100644
--- 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+.
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 9be5c6a..e6046e7 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -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);