[issue26249] Change PyMem_Malloc to use pymalloc allocator

STINNER Victor report at bugs.python.org
Thu Mar 10 04:47:41 EST 2016


STINNER Victor added the comment:

> Does the API doc say anything about the GIL, for example?

I modified Python to add assert(PyGILState_Check()); in PyMem_Malloc() and other functions.

Sadly, I found a bug in Numpy: Numpy releases the GIL for performance but call PyMem_Malloc() with the GIL released. I proposed a fix:
https://github.com/numpy/numpy/pull/7404

I guess that the fix is obvious and will be quickly merged, but it means that other libraries may have the issue.

Using the issue #26516 (PYTHONMALLOC=debug), we can check PyGILState_Check() at runtime, but there is currently an issue related to sub-interpreters. The assertion fails in support.run_in_subinterp(), function used by test_threading and test_capi for example.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26249>
_______________________________________


More information about the Python-bugs-list mailing list