Repository navigation
gh-156910: Add free-threading regression test for type_set_abstractmethods() deadlock - #161195
Open
davidwelling2 wants to merge 1 commit into
Open
davidwelling2 wants to merge 1 commit into
davidwelling2 wants to merge 1 commit into
Conversation
…ractmethods() deadlock
davidwelling2
force-pushed
the
gh-156910-abstractmethods-test
branch
from
November 2, 2026 16:38
241b0fc to
c3d4f27
Compare
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.
Follow-up to gh-156948, which fixed the deadlock but didn't add a test.
This adds
test_abstractmethods_and_registertotest_free_threading/test_type.py. It races ABC classcreation (
type_set_abstractmethods()stops the world underTYPE_LOCK) againstcollections.abc.Sequence.register()(_PyType_SetFlagsRecursive()stops the world withTYPE_LOCKpinned), with a
gc.collect()thread to add contention on the stop-the-world mutex.Tested on a
--disable-gil --with-pydebugbuild: on main before gh-159972, reverting theObjects/typeobject.cchange from gh-156948 made the test hang in 7/7 runs (killed at 120s);with it, it passed 20/20 (~2s each). It also passes 20/20 on current main after gh-159972
(gh-158195), which reworked how TYPE_LOCK interacts with stop-the-world, so the test now
guards both fixes.
This should be backported to 3.15 only. 3.14's
type_set_abstractmethods()doesn't stop the world,so it doesn't have this bug.
AI assistance was used in preparing this change; I have reviewed and tested it.