[Zodb-checkins] CVS: ZODB3/persistent - cPersistence.c:1.75

Tim Peters tim.one at comcast.net
Thu Jan 8 11:53:16 EST 2004


Update of /cvs-repository/ZODB3/persistent
In directory cvs.zope.org:/tmp/cvs-serv26170/persistent

Modified Files:
	cPersistence.c 
Log Message:
changed():  the refcount on self wasn't incremented when self was placed
in a new tuple.  If the chain of stuff triggered by the
subsequent PyEval_CallObject() happened to trigger cyclic gc, then there
were more gc-visible pointers to self than could be accounted for by
self->ob_refcnt, and in a debug build Python died with an assertion
failure.

The code has always been this way, but Jeremy points out that it didn't
matter in previous versions of ZODB, because "self" was always an
ExtensionClass instance before, and gc ignored those.


=== ZODB3/persistent/cPersistence.c 1.74 => 1.75 ===
--- ZODB3/persistent/cPersistence.c:1.74	Fri Nov 28 11:44:55 2003
+++ ZODB3/persistent/cPersistence.c	Thu Jan  8 11:53:15 2004
@@ -175,9 +175,9 @@
 	    Py_DECREF(meth);
 	    return -1;
 	}
+	Py_INCREF(self);
 	PyTuple_SET_ITEM(arg, 0, (PyObject *)self);
 	result = PyEval_CallObject(meth, arg);
-	PyTuple_SET_ITEM(arg, 0, NULL);
 	Py_DECREF(arg);
 	Py_DECREF(meth);
 	if (result == NULL)
@@ -244,8 +244,8 @@
   {"__getstate__", (PyCFunction)Per__getstate__, METH_NOARGS,
    pickle___getstate__doc },
 
-  PICKLE_SETSTATE_DEF 
-  PICKLE_GETNEWARGS_DEF 
+  PICKLE_SETSTATE_DEF
+  PICKLE_GETNEWARGS_DEF
   PICKLE_REDUCE_DEF
 
   {NULL,		NULL}		/* sentinel */




More information about the Zodb-checkins mailing list