https://github.com/python/cpython/commit/4575fb91eab84ec8ee02b7cad7c38b309006a010
commit: 4575fb91eab84ec8ee02b7cad7c38b309006a010
branch: main
author: Neil Schemenauer <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-11-10T14:06:46+05:30
summary:
gh-158194: Exercise type freezing in concurrent setattr deadlock test (#161655)
files:
M Lib/test/test_free_threading/test_type.py
diff --git a/Lib/test/test_free_threading/test_type.py
b/Lib/test/test_free_threading/test_type.py
index 6e750e0bc6084e..f7e4adf2e02ce8 100644
--- a/Lib/test/test_free_threading/test_type.py
+++ b/Lib/test/test_free_threading/test_type.py
@@ -375,6 +375,7 @@ def test_concurrent_setattr_deadlock(self):
# dict mutex and waited for the type lock.
# This is fairly difficult to trigger the race but this N seems to do
# it at least sometimes.
+ type_freeze =
import_helper.import_module("_testlimitedcapi").type_freeze
N = 200
done = False
@@ -401,6 +402,15 @@ def lister():
while not done:
Base.__subclasses__()
+ def freezer():
+ # gh-158194: Exercise type freezing concurrently with slot
+ # updates and competing stop-the-world requests.
+ barrier.wait()
+ for _ in range(10):
+ class Frozen:
+ pass
+ type_freeze(Frozen)
+
def basesetter():
nonlocal done
barrier.wait()
@@ -418,7 +428,7 @@ class B(A):
# to keep the type lock and the stop-the-world mutex contended, which
# is what gets the setters into the window where it happens.
targets = (setter, setter, subclasser, subclasser,
- lister, lister, basesetter)
+ lister, lister, basesetter, freezer)
barrier = threading.Barrier(len(targets))
threads = [Thread(target=target) for target in targets]
with threading_helper.start_threads(threads):
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]