New submission from Stefano Rivera:

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.

----------
components: Library (Lib)
files: pep384-pydbg.patch
keywords: patch
messages: 278381
nosy: stefanor
priority: normal
severity: normal
status: open
title: Don't support the PEP384 stable ABI in pydebug builds
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45040/pep384-pydbg.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28401>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to