Strange and hard to reproduce crash

Lisandro Dalcin dalcinl at
Mon Oct 30 17:05:49 CST 2006

On 10/30/06, Fernando Perez < at> wrote:
> On 10/30/06, Charles R Harris <charlesr.harris at> wrote:
> >  I suspect the real problem is that the refcount keeps going up. Even if it
> > was unsigned it would eventually wrap to zero and with a bit of luck get
> > garbage collected. So probably something isn't decrementing the refcount.
> Oops, my bad: I meant *unsigned long long*, so that the refcount is a
> 64-bit object.  By the time it wraps around, you'll have run out of
> memory long ago.  Having 32 bit ref counters can potentially mean you
> run out of the counter before you run out of RAM on a system with
> sufficient memory.
> Cheers,

FYI, this is what is defined in Include/object.h

/* PyObject_HEAD defines the initial segment of every PyObject. */
#define PyObject_HEAD			\
	_PyObject_HEAD_EXTRA		\
	Py_ssize_t ob_refcnt;		\
	struct _typeobject *ob_type;

#define Py_INCREF(op) (				\

#define Py_DECREF(op)					\
	    --(op)->ob_refcnt != 0)			\
		_Py_CHECK_REFCNT(op)			\
	else						\
		_Py_Dealloc((PyObject *)(op))

And '_Py_CHECK_REFCNT' macro will finally call Py_FatalError

'ob_refcnt' is a  Py_ssize_t integer, so I think you will not be able
to overflow it, unless in case of C code with refcounting bugs. Am I

Lisandro Dalcín
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

More information about the Numpy-discussion mailing list