]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.7] bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770...
authorVictor Stinner <vstinner@redhat.com>
Thu, 11 Apr 2019 20:30:31 +0000 (22:30 +0200)
committerGitHub <noreply@github.com>
Thu, 11 Apr 2019 20:30:31 +0000 (22:30 +0200)
commit9e23f0a27cb8bf6e4ea1d2aef36a91502282bbc9
tree388f7d0875c63ac435b5a40d8abf4cb65e6b1915
parentac31da8f3710f9f9b8dbb4c36b2108fb1e5b4a48
[3.7] bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770) (GH-12788)

* bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770)

Replace _PyMem_IsFreed() function with _PyMem_IsPtrFreed() inline
function. The function is now way more efficient, it became a simple
comparison on integers, rather than a short loop. It detects also
uninitialized bytes and "forbidden bytes" filled by debug hooks
on memory allocators.

Add unit tests on _PyObject_IsFreed().

(cherry picked from commit 2b00db68554422ec37faba2a80179a0172df6349)

* bpo-36389: Change PyMem_SetupDebugHooks() constants (GH-12782)

Modify CLEANBYTE, DEADDYTE and FORBIDDENBYTE constants: use 0xCD,
0xDD and 0xFD, rather than 0xCB, 0xBB and 0xFB, to use the same byte
patterns than Windows CRT debug malloc() and free().

(cherry picked from commit 4c409beb4c360a73d054f37807d3daad58d1b567)
Doc/c-api/memory.rst
Include/internal/mem.h
Include/pymem.h
Lib/test/test_capi.py
Misc/NEWS.d/next/C API/2019-04-11-12-20-35.bpo-36389.P9QFoP.rst [new file with mode: 0644]
Modules/_testcapimodule.c
Objects/object.c
Objects/obmalloc.c