[issue18203] Replace calls to malloc() with PyMem_Malloc()

STINNER Victor report at bugs.python.org
Fri Jun 14 00:07:03 CEST 2013


STINNER Victor added the comment:

>> We have to be careful with the GIL: PyMem_*() functions can only be
>> called when holding the GIL.

> (...)
> I think there's a potential problem here :)

I didn't understand the motivation to require the GIL held for PyMem_Malloc(). I searched in the source code history and on the Internet (archives of python-dev). In my opinion, the restiction is motivated by a bug: PyMem_Malloc() calls (indirectly) PyObject_Malloc() in debug mode, and PyObject_Malloc() is not thread-safe.

I opened a thread on python-dev to discuss this point.

----------

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


More information about the Python-bugs-list mailing list