Title: Make hashlib related modules thread-safe without the GIL · Issue #111916 · python/cpython · GitHub
Open Graph Title: Make hashlib related modules thread-safe without the GIL · Issue #111916 · python/cpython
X Title: Make hashlib related modules thread-safe without the GIL · Issue #111916 · python/cpython
Description: 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: Modules/_blake2/blake2b_impl....
Open Graph Description: 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. Relev...
X Description: 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. R...
Opengraph URL: https://github.com/python/cpython/issues/111916
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make hashlib related modules thread-safe without the GIL","articleBody":"# Feature or enhancement\r\n\r\nThe 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.\r\n\r\nRelevant files:\r\n* Modules/_blake2/blake2b_impl.c\r\n* Modules/_blake2/blake2s_impl.c\r\n* Modules/_hashopenssl.c\r\n* Modules/hashlib.h\r\n* Modules/md5module.c\r\n* Modules/sha1module.c\r\n* Modules/sha2module.c\r\n* Modules/sha3module.c\r\n\r\nBasic idea:\r\n1. Replace `PyThread_type_lock lock` with `PyMutex`. 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 GIL\r\n2. Add a field `bool use_mutex` to indicate if the code should lock the mutex. This should always be set to `true` in `Py_NOGIL`. In the default build, we should dynamically set it to `true` in places where we previously allocated `self-\u003elock`\r\n3. Update `ENTER_HASHLIB` and `EXIT_HASHLIB` macros.\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-111981\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2023-11-09T21:09:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/111916/cpython/issues/111916"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c2ad7345-bae0-986e-799b-c2655e25c664 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D5E:3BAB6B:81A491:A9F389:696B1769 |
| html-safe-nonce | a226959c4f387302241fbbd465feb0f377371702650778b00d499eb0282a18ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDVFOjNCQUI2Qjo4MUE0OTE6QTlGMzg5OjY5NkIxNzY5IiwidmlzaXRvcl9pZCI6IjE0MTA1MzI0MDc4Mzg5NzE3NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d4f0d266eb86d4dface46c64bc79e8a796a16ddfdac00c0ebf09e8c86e9dd889 |
| hovercard-subject-tag | issue:1986406888 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/111916/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ff6792a628e5991a28d348d2d1492dd796a3674b1d869da4c8243890333205e6/python/cpython/issues/111916 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ff6792a628e5991a28d348d2d1492dd796a3674b1d869da4c8243890333205e6/python/cpython/issues/111916 |
| og:image:alt | 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. Relev... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colesbury |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width