2011/9/28 Alex Pyattaev <alex.pyatt...@gmail.com> > Hi! > I have a quite sophisticated program that can be summarized as follows: > 1. Save a pypy object pointer inside C program. Here I call Py_XINCREF so > that > it does not get deleted. > 2. Do some logic, move this reference around C code. > 3. Return a python tuple via typemap, here I am probably supposed to return > a > borrowed reference. And in Python2 it works just fine. BUT. In pypy, for > some > reason, it causes segfault with following message: > """ > Fatal error in cpyext, CPython compatibility layer, calling PyTuple_SetItem > Either report a bug or consider not using this particular extension > <InvalidPointerException object at 0x14a87a8> > RPython traceback: > File "module_cpyext_api_1.c", line 28965, in PyTuple_SetItem > File "module_cpyext_pyobject.c", line 1018, in CpyTypedescr_realize > Segmentation fault > """ > If I call Py_XINCREF before returning the object, the crash does not happen > and the memory does not seem to be leaking (at least not noticeably massive > amounts of it). So it seems that PyPy is somewhat incompatible with Python2 > in > that matter. > If you want I could send the code example that triggers the bug (it IS > quite > large app, which might have many more bugs apart from this, but still). >
Isn't PyTuple_SetItem supposed to "steal" the reference? In this case you'd better INCREF the object if it is globally shared. -- Amaury Forgeot d'Arc
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev