-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
PyMem_Malloc(): check that the GIL is hold in debug hooks #70750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
With the issue bpo-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(): Python 2 doc doesn't say anything about the GIL: 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 bpo-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: numpy/numpy#7404 Attached patch changes debug hooks on PyMem_Malloc() to ensure that the GIL is hold. |
New changeset 58644086c195 by Victor Stinner in branch 'default': |
I pushed the patch (I added an unit test). If too many users complain, we can revert the change since it's now a small change. |
New changeset ae76a1046bb9 by Victor Stinner in branch 'default': |
New changeset 5b4f173f0690 by Victor Stinner in branch 'default': New changeset d6d64168ee8c by Victor Stinner in branch 'default': |
New changeset 959e58cfbde9 by Victor Stinner in branch 'default': |
New changeset 73d8adc0d5ea by Victor Stinner in branch '3.5': |
Reopen. I found and fixed two bugs in os and _overlapped modules (_overlapped is used by asyncio on Windows). |
New changeset ce62df22f3bf by Victor Stinner in branch '3.5': |
Hum ok, all buildbots look to be happy again :-) I close the issue (again). |
New changeset 7b079adb0774 by Victor Stinner in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: