You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2019-04-24.22:58:10.873>created_at=<Date2019-03-28.23:01:42.956>labels= ['build', '3.8']
title='Make release and debug ABI compatible'updated_at=<Date2021-04-02.13:45:45.078>user='https://github.com/vstinner'
When Python is built in debug mode, PyObject gets 2 new fields: _ob_prev and _ob_next. These fields change the offset of following fields in the PyObject structure and so breaks the ABI.
I propose to modify the debug build (Py_DEBUG) to not imply Py_TRACE_REFS anymore. Antoine Pitrou proposed this idea when the C API was discussed to get a stable ABI.
Another more radical idea is to completely remove Py_TRACE_REFS special build.
Another more radical idea is to completely remove Py_TRACE_REFS special build.
I wrote PR 12614 to implement this idea. I wrote it to see which code depends on it:
commit 6350949 (HEAD -> remove_trace_refs, origin/remove_trace_refs)
Author: Victor Stinner <[email protected]>
Date: Thu Mar 28 23:26:58 2019 +0100
WIP: bpo-36465: Remove Py_TRACE_REFS special build
Remove _ob_prev and _ob_next fields of PyObject when Python is
compiled in debug mode to make debug ABI closer to the release ABI.
Remove:
* sys.getobjects()
* PYTHONDUMPREFS environment variable
* _PyCoreConfig.dump_refs
* PyObject._ob_prev and PyObject._ob_next fields
* _PyObject_HEAD_EXTRA and _PyObject_EXTRA_INIT macros
* _Py_AddToAllObjects()
* _Py_PrintReferenceAddresses()
* _Py_PrintReferences()
* _Py_ForgetReference(op) is replaced with _Py_INC_TPFREES(op)
I never used PYTHONDUMPREFS. I just tried in Python 3.7: Python does crash with this option... so this option doesn't sound popuplar. Otherwise, many users would complain.
I never used sys.getobjects() neither, but I can imagine that someone might want to use for very specific needs. So maybe it's safer to not immediately remove the feature. At least, a deprecation period would be needed.
I suggest to reject PR 12614 and not remove Py_TRACE_REFS.
Since my goal here is to support a C extension compiled in release mode on a Python compiled in debug mode, Py_TRACE_REFS should be a new separated ABI since it modify Py_INCREF/Py_DECREF. Maybe a new configure option should be added to opt-in for Py_TRACE_REFS and add "t" (T stands for Trace references) to SOABI.
Activity
vstinner commentedon Mar 28, 2019
When Python is built in debug mode, PyObject gets 2 new fields: _ob_prev and _ob_next. These fields change the offset of following fields in the PyObject structure and so breaks the ABI.
I propose to modify the debug build (Py_DEBUG) to not imply Py_TRACE_REFS anymore. Antoine Pitrou proposed this idea when the C API was discussed to get a stable ABI.
Another more radical idea is to completely remove Py_TRACE_REFS special build.
vstinner commentedon Mar 28, 2019
I wrote PR 12614 to implement this idea. I wrote it to see which code depends on it:
commit 6350949 (HEAD -> remove_trace_refs, origin/remove_trace_refs)
Author: Victor Stinner <[email protected]>
Date: Thu Mar 28 23:26:58 2019 +0100
I never used PYTHONDUMPREFS. I just tried in Python 3.7: Python does crash with this option... so this option doesn't sound popuplar. Otherwise, many users would complain.
I never used sys.getobjects() neither, but I can imagine that someone might want to use for very specific needs. So maybe it's safer to not immediately remove the feature. At least, a deprecation period would be needed.
I suggest to reject PR 12614 and not remove Py_TRACE_REFS.
vstinner commentedon Mar 28, 2019
PR 12615 changes Py_DEBUG to no longer imply Py_TRACE_REFS. IMHO it's a more reasonable approach.
I'm not sure if it's enough to magically get exactly the same ABI than Python built in release mode.
vstinner commentedon Apr 23, 2019
Since my goal here is to support a C extension compiled in release mode on a Python compiled in debug mode, Py_TRACE_REFS should be a new separated ABI since it modify Py_INCREF/Py_DECREF. Maybe a new configure option should be added to opt-in for Py_TRACE_REFS and add "t" (T stands for Trace references) to SOABI.
vstinner commentedon Apr 24, 2019
I started a thread on python-dev to discuss this issue:
"[Python-Dev] Use C extensions compiled in release mode on a Python compiled in debug mode"
https://mail.python.org/pipermail/python-dev/2019-April/157178.html
It's a follow-up of my previous thread:
"[Python-Dev] No longer enable Py_TRACE_REFS by default in debug build"
https://mail.python.org/pipermail/python-dev/2019-April/157015.html
[-]No longer enable Py_TRACE_REFS by default in debug build[/-][+]Make release and debug ABI compatible[/+]vstinner commentedon Apr 24, 2019
New changeset f4e4703 by Victor Stinner in branch 'master':
bpo-36465: Make release and debug ABI compatible (GH-12615)
f4e4703
vstinner commentedon Apr 24, 2019
New changeset 235e7b2 by Victor Stinner in branch 'master':
bpo-36465: Fix test_regrtest on Windows (GH-12945)
235e7b2
vstinner commentedon Feb 17, 2020
New changeset a784759 by Hai Shi in branch 'master':
bpo-36465: Update doc of init_config.rst (GH-18520)
a784759
vstinner commentedon Apr 2, 2021
New changeset 3359cab by Victor Stinner in branch 'master':
bpo-43688: Support the limited C API in debug mode (GH-25131)
3359cab