[pypy-dev] cpyext: Detecting pypy and other issues

Roger Binns rogerb at rogerbinns.com
Mon May 2 23:04:48 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/02/2011 03:12 AM, Armin Rigo wrote:
> It is arguably a bug in your module, 

The rule seems to be that if the C code saves the value of *any* PyObject*
in a static variable then an incref must be done first.  I have actually
been doing this for everything (including PyTypeObject) except for the
module object itself.

> The point is that if it is was possible, then doing so in
> CPython would cause the module to see its refcount drop to zero, and
> be freed, which makes the pointer in the static global variable
> invalid.

This wouldn't have affected me.  There is no way you could have called a
function provided by the module if the module itself had been freed.

My other issue is happening where the object struct has a PyObject * that is
allocated with PyList_New(0) in the _new method.  Later on PyList_ methods
crash.  The debugger is showing a refcount of 140737353674481 so something
has gone horribly wrong ...

Roger



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk2/HGwACgkQmOOfHg372QT9qgCfWvr9rjt0jsV0r/2wnWk5Tq3Q
b+UAniNU0scFslq1TqQeowa/XZYICxh3
=HyOO
-----END PGP SIGNATURE-----



More information about the pypy-dev mailing list