Attached is another diagnostic patch which you might apply to Python.
If you apply this patch, you WILL need to rebuild Zope to include it.
What it will do is complain to stderr if an object is INCREF'd from
refcount 0. It also silences the complaint for the one area which I
know revives dead objects.
This patch will probably cause a crash after an erroneous incref-from-0
is detected, since it doesnt actually DO the incref in that case.
The intent is to find a case in the code where an object is held between
threads; one thread decrefs to zero, the other thread increfs, causing a
revive -- but too late to save the patient.
Zope Corporation http://www.zope.com/
--- Include/object.h.orig Thu Mar 14 16:44:36 2002
+++ Include/object.h Thu Mar 14 16:54:29 2002
@@ -442,7 +442,7 @@
#define _Py_NewReference(op) ((op)->ob_refcnt = 1)
-#define Py_INCREF(op) ((op)->ob_refcnt++)
+#define Py_INCREF(op) ((op)->ob_refcnt > 0 ? (op)->ob_refcnt++ :
+fprintf(stderr,"Eeek! Increfing an object from refct 0 at %s:%d\n",__FILE__,__LINE__)
#define Py_DECREF(op) \
if (--(op)->ob_refcnt != 0) \
--- Objects/classobject.c.orig Thu Mar 14 17:04:40 2002
+++ Objects/classobject.c Thu Mar 14 17:01:36 2002
@@ -535,7 +535,8 @@
#else /* !Py_TRACE_REFS */
/* Py_INCREF boosts _Py_RefTotal if Py_REF_DEBUG is defined */
+ /* Py_INCREF(inst); */
+ inst->ob_refcnt++; /* we dont want to trap this one */
#endif /* !Py_TRACE_REFS */
/* Save the current exception, if any. */