Make hashlib related modules thread-safe without the GIL #111916
Closed
Labels
3.13
new features, bugs and security fixes
extension-modules
C modules in the Modules dir
topic-free-threading
type-feature
A feature request or enhancement
Feature or enhancement
The hashlib based modules already have some locking to make some operations thread-safe (with the GIL), but the logic isn't sufficient if running with the GIL disabled.
Relevant files:
Basic idea:
PyThread_type_lock lockwithPyMutex. This should be both simpler and faster in general and avoid the need for dynamically assigning a lock, which can pose thread-safety issues without the GILbool use_mutexto indicate if the code should lock the mutex. This should always be set totrueinPy_NOGIL. In the default build, we should dynamically set it totruein places where we previously allocatedself->lockENTER_HASHLIBandEXIT_HASHLIBmacros.Linked PRs
The text was updated successfully, but these errors were encountered: