Message389956
Currently, setup.py doesn't build xxlimited and xxlimited_35 extension modules with the limited C API if Python is built in debug mode. I only found two functions affected by Py_DEBUG macro in the limited C API: Py_INCREF() and Py_DECREF().
Example:
---
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
#define Py_REF_DEBUG
#endif
static inline void _Py_INCREF(PyObject *op)
{
#ifdef Py_REF_DEBUG
_Py_RefTotal++;
#endif
op->ob_refcnt++;
}
#define Py_INCREF(op) _Py_INCREF(_PyObject_CAST(op))
---
If Py_DEBUG is defined (Python built in debug mode), Py_INCREF() increments the private _Py_RefTotal variable.
The limited C API is supposed to provide a stable ABI, but Py_INCREF() leaks _Py_RefTotal implementation if Python is built in debug mode.
I propose to modify Py_INCREF() and Py_DECREF() of the limited C API to always declare them as opaque function calls. The regular (non limited) C API will continue to use the same static inline functions.
See also https://github.com/python/cpython/pull/25115 and bpo-41111 "[C API] Convert a few stdlib extensions to the limited C API (PEP 384)".
Note: Py_XINCREF() and Py_XDECREF() should be fine. |
|
Date |
User |
Action |
Args |
2021-04-01 06:47:31 | vstinner | set | recipients:
+ vstinner |
2021-04-01 06:47:31 | vstinner | set | messageid: <1617259651.04.0.276896882913.issue43688@roundup.psfhosted.org> |
2021-04-01 06:47:31 | vstinner | link | issue43688 messages |
2021-04-01 06:47:30 | vstinner | create | |
|