[Python-checkins] r42177 - in python/trunk: Lib/bsddb/test/test_1413192.py Lib/bsddb/test/test_all.py Lib/test/test_bsddb3.py Misc/NEWS Modules/_bsddb.c
neal.norwitz
python-checkins at python.org
Wed Jan 25 06:21:58 CET 2006
Author: neal.norwitz
Date: Wed Jan 25 06:21:55 2006
New Revision: 42177
Added:
python/trunk/Lib/bsddb/test/test_1413192.py
Modified:
python/trunk/Lib/bsddb/test/test_all.py
python/trunk/Lib/test/test_bsddb3.py
python/trunk/Misc/NEWS
python/trunk/Modules/_bsddb.c
Log:
Fix bug #1413192, fix seg fault in bsddb if a txn was deleted before the env.
Will backport.
Added: python/trunk/Lib/bsddb/test/test_1413192.py
==============================================================================
--- (empty file)
+++ python/trunk/Lib/bsddb/test/test_1413192.py Wed Jan 25 06:21:55 2006
@@ -0,0 +1,16 @@
+
+# http://python.org/sf/1413192
+#
+# This test relies on the variable names, see the bug report for details.
+# The problem was that the env was deallocated prior to the txn.
+
+from bsddb import db
+
+env_name = '.'
+
+env = db.DBEnv()
+env.open(env_name, db.DB_CREATE | db.DB_INIT_TXN)
+the_txn = env.txn_begin()
+
+map = db.DB(env)
+map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0666, txn=the_txn)
Modified: python/trunk/Lib/bsddb/test/test_all.py
==============================================================================
--- python/trunk/Lib/bsddb/test/test_all.py (original)
+++ python/trunk/Lib/bsddb/test/test_all.py Wed Jan 25 06:21:55 2006
@@ -46,6 +46,12 @@
def suite():
+ try:
+ # this is special, it used to segfault the interpreter
+ import test_1413192
+ except:
+ pass
+
test_modules = [
'test_associate',
'test_basics',
Modified: python/trunk/Lib/test/test_bsddb3.py
==============================================================================
--- python/trunk/Lib/test/test_bsddb3.py (original)
+++ python/trunk/Lib/test/test_bsddb3.py Wed Jan 25 06:21:55 2006
@@ -22,6 +22,12 @@
def suite():
+ try:
+ # this is special, it used to segfault the interpreter
+ import bsddb.test.test_1413192
+ except:
+ pass
+
test_modules = [
'test_associate',
'test_basics',
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Wed Jan 25 06:21:55 2006
@@ -216,6 +216,9 @@
Extension Modules
-----------------
+- Bug #1413192, fix seg fault in bsddb if a transaction was deleted
+ before the env.
+
- Patch #1103116: Basic AF_NETLINK support.
- Bug #1402308, (possible) segfault when using mmap.mmap(-1, ...)
Modified: python/trunk/Modules/_bsddb.c
==============================================================================
--- python/trunk/Modules/_bsddb.c (original)
+++ python/trunk/Modules/_bsddb.c Wed Jan 25 06:21:55 2006
@@ -266,6 +266,7 @@
typedef struct {
PyObject_HEAD
DB_TXN* txn;
+ PyObject *env;
#ifdef HAVE_WEAKREF
PyObject *in_weakreflist; /* List of weak references */
#endif
@@ -928,6 +929,8 @@
DBTxnObject* self = PyObject_New(DBTxnObject, &DBTxn_Type);
if (self == NULL)
return NULL;
+ Py_INCREF(myenv);
+ self->env = (PyObject*)myenv;
#ifdef HAVE_WEAKREF
self->in_weakreflist = NULL;
#endif
@@ -938,11 +941,10 @@
#else
err = txn_begin(myenv->db_env, parent, &(self->txn), flags);
#endif
- /* TODO add a weakref(self) to the self->myenvobj->open_child_weakrefs
- * list so that a DBEnv can refuse to close without aborting any open
- * open DBTxns and closing any open DBs first. */
MYDB_END_ALLOW_THREADS;
if (makeDBError(err)) {
+ Py_DECREF(self->env);
+ PyObject_Del(self);
self = NULL;
}
return self;
@@ -973,6 +975,7 @@
}
#endif
+ Py_DECREF(self->env);
PyObject_Del(self);
}
More information about the Python-checkins
mailing list