[issue26563] PyMem_Malloc(): check that the GIL is held in debug hooks
STINNER Victor
report at bugs.python.org
Mon Mar 14 18:52:53 EDT 2016
New submission from STINNER Victor:
With the issue #26558, debug hooks of PyObject_Malloc() now checks that the GIL is hold.
I left PyMem_Malloc() unchanged, because I am not 100% sure that it's ok yet to implement the same check in PyMem_Malloc(). So I opened this issue.
Python 3 doc explicitly asks that the GIL is hold to call PyMem_Malloc():
https://docs.python.org/dev/c-api/memory.html#memory-interface
Python 2 doc doesn't say anything about the GIL:
https://docs.python.org/2/c-api/memory.html#memory-interface
Usually, functions prefixed by "Py" require the GIL to be hold.
In practice, currently PyMem_Malloc() is implemented with malloc() which is thread-safe.
In the issue #26249, I tested numpy, lxml, Pillow and cryptography with all debug hooks enabled, including GIL checks in PyMem_Malloc() and PyObject_Malloc(). I only found one bug in numpy: https://github.com/numpy/numpy/pull/7404
Attached patch changes debug hooks on PyMem_Malloc() to ensure that the GIL is hold.
----------
files: pymem_gil.patch
keywords: patch
messages: 261787
nosy: haypo
priority: normal
severity: normal
status: open
title: PyMem_Malloc(): check that the GIL is held in debug hooks
versions: Python 3.6
Added file: http://bugs.python.org/file42165/pymem_gil.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26563>
_______________________________________
More information about the Python-bugs-list
mailing list