GeezerVison is showing github.com — gh-159041: Fix use-after-free in asyncio task tracking during thread state cleanup by ngoldbaum · Pull Request #159073 · python/cpython
Conversation
ngoldbaum
commented
Oct 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Centralize transfer of remaining tasks to the interpreter in free_threadstate(), before normal thread-state unlinking and GIL release. Keep memory deallocation separate for initialization failures and deferred daemon-thread cleanup.
Add regression tests for both thread-state and interpreter cleanup paths.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Move lingering asyncio tasks to the interpreter only after all
finalizer-capable thread-state cleanup has completed. Also transfer tasks
created by finalizers during interpreter shutdown.
Add regression tests for both thread-state and interpreter cleanup paths.
|
Ping @colesbury @msullivan since you two have been reviewing asyncio changes recently and Kumar is busy.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ngoldbaum
changed the title
gh-159041: Fix asyncio task tracking during thread state cleanup
gh-159041: Fix use-after-free in asyncio task tracking during thread state cleanup
Oct 16, 2026
…ove to more appropriate spot
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Sorry, @ngoldbaum and @kumaraditya303, I could not cleanly backport this to 3.14 due to a conflict.
Please backport manually with cherry_picker, see the devguide for more information.
cherry_picker 999855b07f9b795ca88ac3349060a06c116a1037 3.14
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot AMD64 CentOS9 Refleaks 3.x (tier-1) has failed when building commit 999855b.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/853/builds/4406) and take a look at the build logs.
- Check if the failure is related to this commit (999855b) or if it is a false positive.
- If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.
You can take a look at the buildbot page here:
https://buildbot.python.org/#/builders/853/builds/4406
Failed tests:
Failed subtests:
- test_calling_conventions - test.test_profile.ProfileTest.test_calling_conventions
Summary of the results of the build (if available):
==
Click to see traceback logs
Traceback (most recent call last):
File "/var/lib/buildbot/worker/cstratak-CentOS9-x86_64/3.x.cstratak-CentOS9-x86_64.refleak/build/Lib/test/test_profile.py", line 90, in test_calling_conventions
self.assertIn(self.expected_max_output, res,
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"Profiling {0!r} didn't report max:\n{1}".format(stmt, res))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: ':0(max)' not found in ' 2 function calls in -0.001 seconds\n\n Random listing order was used\n\n ncalls tottime percall cumtime percall filename:lineno(function)\n 0 0.000 0.000 profile:0(profiler)\n 1 -0.001 -0.001 -0.001 -0.001 profile:0(max(*([0],), **dict(key=int)))\n 1 0.000 0.000 0.000 0.000 :0(exec)\n\n\n' : Profiling 'max(*([0],), **dict(key=int))' didn't report max:
2 function calls in -0.001 seconds
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
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.
|