Py_DECREF() in interpreter doesn't call _PyReftracerTrack(op, PyRefTracer_DESTROY) #130382
Copy link
Copy link
Closed
Closed
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Lines 72 to 85 in 6c450f4
| #undef Py_DECREF | |
| #define Py_DECREF(arg) \ | |
| do { \ | |
| PyObject *op = _PyObject_CAST(arg); \ | |
| if (_Py_IsImmortal(op)) { \ | |
| _Py_DECREF_IMMORTAL_STAT_INC(); \ | |
| break; \ | |
| } \ | |
| _Py_DECREF_STAT_INC(); \ | |
| if (--op->ob_refcnt == 0) { \ | |
| destructor dealloc = Py_TYPE(op)->tp_dealloc; \ | |
| (*dealloc)(op); \ | |
| } \ | |
| } while (0) |
Tracemalloc only handles PyRefTracer_CREATE events and we don't have any tests for PyRefTracer_DESTROY events.
EDIT: _testcapimodule.c tests PyRefTracer_DESTROY events, but only through the C API and not the Python interpreter.
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
tom-pytel commentedon Feb 24, 2025
There is a super-basic reftracer test in
_testcapimodule.c, but no python interface that I can see, so added one to tracemalloc module to keep track of created and destroyed refs. Do you want this?Example:
Run:
pythongh-130382: add missing _PyReftracerTrack to ceval DECREF
pythongh-130382: Add missing reftracer call to ceval.c
gh-130382: add missing `_PyReftracerTrack` to ceval `Py_DECREF` (#130689
[3.13] pythongh-130382: add missing `_PyReftracerTrack` to ceval `Py_…
[3.13] gh-130382: add missing `_PyReftracerTrack` to ceval `Py_DECREF` (
pythongh-130382: add missing `_PyReftracerTrack` to ceval `Py_DECREF` (…