Author stefanor
Recipients stefanor
Date 2016-10-09.17:31:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1476034292.17.0.316209799179.issue28401@psf.upfronthosting.co.za>
In-reply-to
Content
setup.py build for a library using py_limited_api will always generate a stable ABI tagged shared library, even under the pydebug interpreter.

This means that extensions that are built for a pydebug interpreter may be accidentally (and brokenly) imported in a non-dbg interpreter and vice-versa.

e.g. in python-librtmp, with cffi 1.8.3:
$ python3-dbg setup.py build
...
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -Og -fdebug-prefix-map=/build/python3.5-H9Fri6/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5-pydebug/build/temp.linux-x86_64-3.5-pydebug/librtmp._librtmp.o -lrtmp -o build/lib.linux-x86_64-3.5-pydebug/librtmp/_librtmp.abi3.so

Then:
$ cd build/lib.linux-x86_64-3.5-pydebug
$ python3 -c 'import librtmp'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/python-librtmp-0.3.0/build/lib.linux-x86_64-3.5-pydebug/librtmp/__init__.py", line 8, in <module>
    from ._librtmp import ffi, lib as librtmp
ImportError: /tmp/python-librtmp-0.3.0/build/lib.linux-x86_64-3.5-pydebug/librtmp/_librtmp.abi3.so: undefined symbol: _Py_RefTotal

setuptools decides whether to use the stable ABI, by looking at imp.get_suffixes(). And obviously, the importer is looking at that too. So, the stable ABI tag should simply not be in there.

PEP3149 agrees with this. It has this quote from Martin v. Löwis:
 --with-pydebug would not be supported by the stable ABI because this changes the layout of PyObject , which is an exposed structure.

So, here's a patch, to disable support for the stable ABI under pydebug builds.
History
Date User Action Args
2016-10-09 17:31:32stefanorsetrecipients: + stefanor
2016-10-09 17:31:32stefanorsetmessageid: <1476034292.17.0.316209799179.issue28401@psf.upfronthosting.co.za>
2016-10-09 17:31:32stefanorlinkissue28401 messages
2016-10-09 17:31:31stefanorcreate