I'll wait for the patch where you also silence the dead-raising area in
What if, instead of detecting this situation, we try to detect if the
incref is happening without the interpreter lock held? increfs and
decrefs shouldn't be happening freely and simultaneously even in C code
right? Is holding the interpreter lock the correct way to signal that
you'll be doing increfings and decrefings in C code?
On Thu, 2002-03-14 at 19:10, 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.
> Matt Kromer
> 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);
> + /* Py_INCREF(inst); */
> + inst->ob_refcnt++; /* we dont want to trap this one */
> #endif /* !Py_TRACE_REFS */
> /* Save the current exception, if any. */
Ideas don't stay in some minds very long because they don't like
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -