Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-127266: avoid data races when updating type slots v2#133177
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from13 commits
Commits
Show all changes
24 commits Select commitHold shift + click to select a range
3094372
gh-127266: avoid data races when updating type slots
naschemef447ce4
For update_all_slots(), do updates more safely.
naschemed511ca6
Avoid "empty structure" compile error.
nascheme5e38497
Use apply_slot_updates() for type_setattro().
naschemee9516c7
Merge 'origin/main' into type-slot-ts-v2
nascheme8c74a0c
Reduce number of items in test for slot updates.
nascheme6cd7644
Add TSAN suppression for _Py_slot_tp_getattr_hook.
nascheme3cb2256
Queue update of tp_flags as well.
nascheme47e41c9
Performance, skip stop-the-world when possible.
naschemecb848f1
Merge 'origin/main' into type-slot-ts-v2
nascheme9859ebf
Always clear version after __bases__ update.
nascheme6c74cac
Merge 'origin/main' into type-slot-ts-v2
nascheme583c435
Add test for assigning __bases__.
naschemec01707e
Avoid releasing TYPE_LOCK when stopping the world.
nascheme1b9cad5
Merge 'origin/main' into type-slot-ts-v2
naschemea1c6b05
Add issue number for TSAN suppression.
nascheme3f6222b
Bug fix for type_lock_prevent_release().
nascheme6f218fb
Merge 'origin/main' into type-slot-ts-v2
nascheme2bcf7ba
Add additional assert.
naschemeddfdbd5
Merge 'origin/main' into type-slot-ts-v2
nascheme63b7ae4
Revert test_opcache item size change.
nascheme1a2fee1
Add comment for new unit test.
naschemec1f3ed5
Fix assert for default build.
nascheme41e54e1
Improve function name.
naschemeFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletionsInclude/internal/pycore_interp_structs.h
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
2 changes: 1 addition & 1 deletionInclude/internal/pycore_object.h
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
1 change: 0 additions & 1 deletionInclude/internal/pycore_typeobject.h
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
12 changes: 7 additions & 5 deletionsInclude/object.h
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
3 changes: 0 additions & 3 deletionsInclude/refcount.h
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
26 changes: 26 additions & 0 deletionsLib/test/test_descr.py
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
5 changes: 3 additions & 2 deletionsLib/test/test_opcache.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -576,6 +576,7 @@ class TestRacesDoNotCrash(TestBase): | ||
# Careful with these. Bigger numbers have a higher chance of catching bugs, | ||
# but you can also burn through a *ton* of type/dict/function versions: | ||
ITEMS = 1000 | ||
SMALL_ITEMS = 100 | ||
nascheme marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
LOOPS = 4 | ||
WRITERS = 2 | ||
@@ -619,7 +620,7 @@ class C: | ||
__getitem__ = lambda self, item: None | ||
items = [] | ||
for _ in range(self.SMALL_ITEMS): | ||
item = C() | ||
items.append(item) | ||
return items | ||
@@ -790,7 +791,7 @@ class C: | ||
__getattribute__ = lambda self, name: None | ||
items = [] | ||
for _ in range(self.SMALL_ITEMS): | ||
item = C() | ||
items.append(item) | ||
return items | ||
6 changes: 6 additions & 0 deletionsMisc/NEWS.d/next/Core_and_Builtins/2025-03-14-13-08-20.gh-issue-127266._tyfBp.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
In the free-threaded build, avoid data races caused by updating type slots | ||
or type flags after the type was initially created. For those (typically | ||
rare) cases, use the stop-the-world mechanism. Remove the use of atomics | ||
when reading or writing type flags. The use of atomics is not sufficient to | ||
avoid races (since flags are sometimes read without a lock and without | ||
atomics) and are no longer required. |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.