-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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-112075: Fix dict thread safety issues #119288
Conversation
fbd9677
to
22279c0
Compare
22279c0
to
dc2c785
Compare
dc2c785
to
b98504f
Compare
b98504f
to
2eeb71a
Compare
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.
LGTM!
I think we should backport this to 3.13 |
Fix dict thread safety issues (cherry picked from commit f0ed186) Co-authored-by: Germán Méndez Bravo <[email protected]>
GH-121545 is a backport of this pull request to the 3.13 branch. |
(cherry picked from commit f0ed186) Co-authored-by: Germán Méndez Bravo <[email protected]>
|
Fix dict thread safety issues
Summary:
For dicts, there are a myriad of variables that are atomics. i.e.:
All of these can be accessed in write or read mode. When these are being accessed in write mode, regardless of the status of the dictionary lock, the write should be an atomic store. All reads must be atomic loads if the lock is not held, or can be non-atomic reads otherwise.
This diff goes through all of the
ma_used
use cases and makes sure this holds true.Test Plan:
./configure --disable-gil --with-thread-sanitizer --with-pydebug make -j env TSAN_OPTIONS=suppressions=Tools/tsan/suppressions_free_threading.txt ./python -m test --tsan -j4
All tests passing, no related TSAN issues.
dict
objects thread-safe in--disable-gil
builds #112075