[Zope-dev] more on the segfault saga

Leonardo Rochael Almeida leo@hiper.com.br
18 Mar 2002 17:44:08 -0300


I've applied both patches, however I've changed the incref part a
little. Now it reads:

#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__), (op)->ob_refcnt++)

It's all in one line if my MUA wrapped it. I did it so as to make sure
it doesn't crash in different places than it crashed before.

I'll report anything I find

Cheers, Leo

On Thu, 2002-03-14 at 19:44, Matthew T. Kromer wrote:
> 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/ 
> 
> 
> ----
> 

> 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))
-- 
Ideas don't stay in some minds very long because they don't like
solitary confinement.