Commit 9f68cbc7 authored by Tim Peters's avatar Tim Peters

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.
parent 6af7c473
......@@ -14,7 +14,7 @@
static char cPersistence_doc_string[] =
"Defines Persistent mixin class for persistent objects.\n"
"\n"
"$Id: cPersistence.c,v 1.74 2003/11/28 16:44:55 jim Exp $\n";
"$Id: cPersistence.c,v 1.75 2004/01/08 16:53:15 tim_one Exp $\n";
#include "cPersistence.h"
#include "structmember.h"
......@@ -175,9 +175,9 @@ changed(cPersistentObject *self)
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 @@ static struct PyMethodDef Per_methods[] = {
{"__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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment