[Python-Dev] _Py_RefTotal wrong in Py 2.2.3

Christian Tismer tismer at tismer.com
Sun Nov 16 20:02:48 EST 2003


Hi friends,

over the weekend, I hacked quite a lot on Stackless
with Python 2.2.3, in order to get rid of refcounting
problems with thread pickling.
It tuned out that code objects created wrong refcounts
when unpickling them.

I debuged this down to the very end, until I was sure
my stuff is doing it right. Then I added a small function
that recomputes the actual total refcounts from the
chained list of all objects, and it turned out to be
correct (and also my pickling), but _Py_RefTotal is different.

Before I invest more time into this, please let me know:
Is this a known problem which is solved by moving to
Python 2.3.2, or should I try to find the bug?
I know this is hard to debug for anybody but me, since pickling
of code objects is a Stackless only feature.

The key might be here:

void
_Py_NewReference(PyObject *op)
{
	_Py_RefTotal++;
	op->ob_refcnt = 1;
	op->_ob_next = refchain._ob_next;
	op->_ob_prev = &refchain;
	refchain._ob_next->_ob_prev = op;
	refchain._ob_next = op;
#ifdef COUNT_ALLOCS
	inc_count(op->ob_type);
#endif
}

It might be that at some place, this function is used when
the refcount is not zero, but I don't know. This would get
_Py_RefTotal and the real refcounts out of sync.

Many thanks -- chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/






More information about the Python-Dev mailing list