mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-127266: avoid data races when updating type slots (gh-131174)
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.
This commit is contained in:
parent
22f0730d40
commit
e414a2d81c
10 changed files with 233 additions and 112 deletions
|
@ -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
|
||||
LOOPS = 4
|
||||
WRITERS = 2
|
||||
|
||||
|
@ -619,7 +620,7 @@ class TestRacesDoNotCrash(TestBase):
|
|||
__getitem__ = lambda self, item: None
|
||||
|
||||
items = []
|
||||
for _ in range(self.ITEMS):
|
||||
for _ in range(self.SMALL_ITEMS):
|
||||
item = C()
|
||||
items.append(item)
|
||||
return items
|
||||
|
@ -790,7 +791,7 @@ class TestRacesDoNotCrash(TestBase):
|
|||
__getattribute__ = lambda self, name: None
|
||||
|
||||
items = []
|
||||
for _ in range(self.ITEMS):
|
||||
for _ in range(self.SMALL_ITEMS):
|
||||
item = C()
|
||||
items.append(item)
|
||||
return items
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue