gh-112075: Fix dict thread safety issues#119288
Merged
DinoV merged 2 commits intopython:mainfrom May 24, 2024
Merged
Conversation
fbd9677 to
22279c0
Compare
22279c0 to
dc2c785
Compare
DinoV
reviewed
May 22, 2024
dc2c785 to
b98504f
Compare
b98504f to
2eeb71a
Compare
Contributor
|
I think we should backport this to 3.13 |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jul 9, 2024
Fix dict thread safety issues (cherry picked from commit f0ed186) Co-authored-by: Germán Méndez Bravo <kronuz@fb.com>
|
GH-121545 is a backport of this pull request to the 3.13 branch. |
|
estyxx
pushed a commit
to estyxx/cpython
that referenced
this pull request
Jul 17, 2024
Fix dict thread safety issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_useduse 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 -j4All tests passing, no related TSAN issues.
dictobjects thread-safe in--disable-gilbuilds #112075