Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-111916: Make hashlib related modules thread-safe without the GIL#111981
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
tomasr8 commented Nov 11, 2023 • edited by gpshead
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by gpshead
Uh oh!
There was an error while loading. Please reload this page.
colesbury left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build errors you're seeing are due to md5module.c being compiled with the limited API, which means internal-only functions like PyMutex_Lock are not available. You should remove these lines from md5module.c:
#ifndef _MSC_VER #include "pyconfig.h" // Py_NOGIL #endif #ifndef Py_NOGIL // Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED #define Py_LIMITED_API 0x030c0000 #endif And instead add:
#ifndef Py_BUILD_CORE_BUILTIN # define Py_BUILD_CORE_MODULE 1 #endif Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
colesbury commented Nov 13, 2023
(I edited my review comment to note that you also should add |
colesbury commented Nov 14, 2023
It looks like some of the generated parts of |
tomasr8 commented Nov 15, 2023
Thanks for the thorough review! I reran AC as you suggested, so hopefully it should be good this time |
colesbury left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
gpshead left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one minor style nit, overall looks great. thanks!
gpshead commented Nov 15, 2023
Yep, the old |
… GIL (python#111981) Always use an individual lock on hash objects when in free-threaded builds. Fixespython#111916
… GIL (python#111981) Always use an individual lock on hash objects when in free-threaded builds. Fixespython#111916
Still a work in progress but I'd be happy for feedback ;)
I'm not entirely sure what to do about
HASHLIB_GIL_MINSIZE. IIUC the original code avoids releasing the GIL and getting a separate lock when the update buffer is short enough. I'm guessing that in the nogil version, we'll have to lock the mutex regardless of the length (i.e. essentially getting rid of the macro)? Is that correct?As a side note, I'm failing to build this PR with the GIL enabled. Running
./configure --with-pydebugandmake -s -j2, I'm getting this error:Even if I add
#include "pyatomic.h"topycore_lock.hI get the same error.. any idea why that is?Fixes#111916