diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-09-18 17:39:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-18 17:39:27 (GMT) |
commit | 74a7f5d2dacd4c05aad0e64a275dae97d18f5355 (patch) | |
tree | d654c4b110caa5290f650689af46d6d6f8a8d59e /Misc/NEWS.d/next | |
parent | 0620bc7f78782cd2e400827aaf834f358250778f (diff) | |
download | cpython-74a7f5d2dacd4c05aad0e64a275dae97d18f5355.zip cpython-74a7f5d2dacd4c05aad0e64a275dae97d18f5355.tar.gz cpython-74a7f5d2dacd4c05aad0e64a275dae97d18f5355.tar.bz2 |
[3.12] gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539) (#109545)
gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539)
On a Python built in debug mode, Py_DECREF() now calls
_Py_NegativeRefcount() if the object is a dangling pointer to
deallocated memory: memory filled with 0xDD "dead byte" by the debug
hook on memory allocators. The fix is to check the reference count
*before* checking for _Py_IsImmortal().
Add test_decref_freed_object() to test_capi.test_misc.
(cherry picked from commit 0bb0d88e2d4e300946e399e088e2ff60de2ccf8c)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Misc/NEWS.d/next')
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2023-09-18-15-35-08.gh-issue-109496.Kleoz3.rst | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-09-18-15-35-08.gh-issue-109496.Kleoz3.rst b/Misc/NEWS.d/next/Core and Builtins/2023-09-18-15-35-08.gh-issue-109496.Kleoz3.rst new file mode 100644 index 0000000..51b2144 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-09-18-15-35-08.gh-issue-109496.Kleoz3.rst @@ -0,0 +1,5 @@ +On a Python built in debug mode, :c:func:`Py_DECREF()` now calls +``_Py_NegativeRefcount()`` if the object is a dangling pointer to +deallocated memory: memory filled with ``0xDD`` "dead byte" by the debug +hook on memory allocators. The fix is to check the reference count *before* +checking for ``_Py_IsImmortal()``. Patch by Victor Stinner. |