diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-16 11:12:53 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-16 11:12:53 (GMT) |
commit | ad524375af042a549d28ec252f3071a595b892b2 (patch) | |
tree | 8d2a755845089be4a06d2c7c185d242ff379907f /Objects | |
parent | 013024ef67b7e5989e4be03f4ff2be22aa753ae0 (diff) | |
download | cpython-ad524375af042a549d28ec252f3071a595b892b2.zip cpython-ad524375af042a549d28ec252f3071a595b892b2.tar.gz cpython-ad524375af042a549d28ec252f3071a595b892b2.tar.bz2 |
Fail if PyMem_Malloc() is called without holding the GIL
Issue #26563: Debug hooks on Python memory allocators now raise a fatal error
if functions of the PyMem_Malloc() family are called without holding the GIL.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/obmalloc.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 8812f59..503fcdf 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -198,7 +198,7 @@ static PyMemAllocatorEx _PyMem_Raw = { static PyMemAllocatorEx _PyMem = { #ifdef Py_DEBUG - &_PyMem_Debug.mem, PYRAWDBG_FUNCS + &_PyMem_Debug.mem, PYDBG_FUNCS #else NULL, PYMEM_FUNCS #endif @@ -321,17 +321,17 @@ PyMem_SetupDebugHooks(void) PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &alloc); } - if (_PyMem.malloc != _PyMem_DebugRawMalloc) { - alloc.ctx = &_PyMem_Debug.mem; - PyMem_GetAllocator(PYMEM_DOMAIN_MEM, &_PyMem_Debug.mem.alloc); - PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &alloc); - } - alloc.malloc = _PyMem_DebugMalloc; alloc.calloc = _PyMem_DebugCalloc; alloc.realloc = _PyMem_DebugRealloc; alloc.free = _PyMem_DebugFree; + if (_PyMem.malloc != _PyMem_DebugMalloc) { + alloc.ctx = &_PyMem_Debug.mem; + PyMem_GetAllocator(PYMEM_DOMAIN_MEM, &_PyMem_Debug.mem.alloc); + PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &alloc); + } + if (_PyObject.malloc != _PyMem_DebugMalloc) { alloc.ctx = &_PyMem_Debug.obj; PyMem_GetAllocator(PYMEM_DOMAIN_OBJ, &_PyMem_Debug.obj.alloc); |