[Zope-dev] more on the segfault saga

Matthew T. Kromer matt@zope.com
Thu, 14 Mar 2002 17:44:46 -0500


This is a multi-part message in MIME format.
--------------070601090705080004030305
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

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  http://www.zope.com/ 



--------------070601090705080004030305
Content-Type: text/plain;
 name="ec.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ec.diff"

Index: lib/Components/ExtensionClass/src/ExtensionClass.c
===================================================================
RCS file: /cvs-repository/Zope/lib/Components/ExtensionClass/src/ExtensionClass.c,v
retrieving revision 1.46.36.1
diff -u -r1.46.36.1 ExtensionClass.c
--- lib/Components/ExtensionClass/src/ExtensionClass.c	4 Oct 2001 14:25:19 -0000	1.46.36.1
+++ 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);
 #endif
 
+  self->ob_refcnt++;
   PyErr_Fetch(&t,&v,&tb);
-  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))

--------------070601090705080004030305--