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
{{ message }}
Repository navigation
Py_TRACE_REFS is not compatible with Py_LIMITED_API #108634
I am confident this is a bug in CPython, not a bug in a third-party project
I have searched the CPython issue tracker,
and am confident this bug has not been reported before
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
A clear and concise description of the bug:
Trying to build a C extension targetting the limited C API (defining Py_LIMITED_API) fails if Python is configured with ./configure --with-trace-refs. Example with PR #108573:
In file included from ./Include/Python.h:44,
from ./Modules/_stat.c:16:
./Include/object.h:62:4: error: #error Py_LIMITED_API is incompatible with Py_TRACE_REFS
62 | # error Py_LIMITED_API is incompatible with Py_TRACE_REFS
| ^~~~~
make: *** [Makefile:3194: Modules/_stat.o] Error 1
The #error comes from Include/object.h:
#if defined(Py_LIMITED_API) && defined(Py_TRACE_REFS)
# error Py_LIMITED_API is incompatible with Py_TRACE_REFS
#endif
The problem is that the PyObject ABI is different: Py_TRACE_REFS adds two members to PyObject structure:
PyObject*_ob_next;
PyObject*_ob_prev;
One solution to make Py_TRACE_REFS compatible with Py_LIMITED_API would be to not add these two members to PyObject, but store the double-linked list outside PyObject. Store it in a different structure, so PyObject stays ABI compatible.
Activity
erlend-aasland commentedon Aug 29, 2023
See also #63083 and #73104
pythongh-108634: Use a hashtable for Py_TRACE_REFS
pythongh-108634: Use a hashtable for Py_TRACE_REFS
pythongh-108634: Py_TRACE_REFS uses a hash table
pythongh-108634: Py_TRACE_REFS uses a hash table
pythongh-108634: Py_TRACE_REFS uses a hash table
pythongh-108634: Py_TRACE_REFS uses a hash table
pythongh-108634: Py_TRACE_REFS uses a hash table
gh-108634: Py_TRACE_REFS uses a hash table (#108663)
pythongh-108634: init_interpreter() returns Py_Status
pythongh-108634: init_interpreter() returns Py_Status
pythongh-108634: init_interpreter() returns Py_Status
pythongh-108634: PyInterpreterState_New() no longer calls Py_FatalErr…
pythongh-108634: PyInterpreterState_New() no longer calls Py_FatalErr…
pythongh-108634: PyInterpreterState_New() no longer calls Py_FatalErr…
pythongh-108634: Add _PyInterpreterState_New() function
gh-108634: PyInterpreterState_New() no longer calls Py_FatalError() (#…