Matthew T. Kromer wrote:

> 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.

extensionclass also brings back the dead; the following patch to Zope's 
extensionclass will turn off the warning when it happens when you apply 
the previous patch that I sent out that complains when an object is 
incref'd from a refcount of zero.

Matt Kromer
Zope Corporation 

Index: lib/Components/ExtensionClass/src/ExtensionClass.c
RCS file: /cvs-repository/Zope/lib/Components/ExtensionClass/src/ExtensionClass.c,v
retrieving revision
diff -u -r1.46.36.1 ExtensionClass.c
--- lib/Components/ExtensionClass/src/ExtensionClass.c  4 Oct 2001 14:25:19 -0000
+++ lib/Components/ExtensionClass/src/ExtensionClass.c  14 Mar 2002 22:43:10 -0000
@@ -3047,8 +3047,9 @@
   fprintf(stderr,"Deallocating a %s\n", self->ob_type->tp_name);
+  self->ob_refcnt++;
-  Py_INCREF(self);             /* Give us a new lease on life */
+ /* Py_INCREF(self);           /* Give us a new lease on life */
   if (subclass_watcher &&
      ! PyObject_CallMethod(subclass_watcher,"destroying","O",self))

Reply via email to