-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
gh-127945: fix thread safety of creating instances of ctypes structures #131716
Conversation
🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit b0e06a0 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131716%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
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.
Looks great! A few minor comments.
ctypes
thread safety auditing (and fixing) #127945In free-threading, concurrent mutations to StgInfo is not thread safe. Therefore to make it thread safe, when modifying StgInfo, this PR adds
STGINFO_LOCK
andSTGINFO_UNLOCK
macros which are used to acquire critical section of the StgInfo. The critical section is write only and is acquired when modifying the StgInfo fields and while setting thedict_final
bit. Once thedict_final
is set, StgInfo is treated as read only and no further modifications are allowed. This allows to avoid acquiring the critical section for most read operations whendict_final
is set (general case).Fixes #128567
Fixes #128570