René's URL Explorer Experiment


Title: gh-151535: Bound _remote_debugging asyncio awaited_by graph recursion by tonghuaroot · Pull Request #151536 · python/cpython · GitHub

Open Graph Title: gh-151535: Bound _remote_debugging asyncio awaited_by graph recursion by tonghuaroot · Pull Request #151536 · python/cpython

X Title: gh-151535: Bound _remote_debugging asyncio awaited_by graph recursion by tonghuaroot · Pull Request #151536 · python/cpython

Description: _remote_debugging.RemoteUnwinder.get_async_stack_trace() walks the target process's asyncio awaited_by graph with an unbounded three-function C recursion (process_task_and_waiters → process_task_awaited_by → process_waiter_task → process_task_and_waiters, in Modules/_remote_debugging/asyncio.c). Each level also stack-allocates char task_obj[SIZEOF_TASK_OBJ] (4096 bytes), so a deep or cyclic graph in the target overflows the debugger's C stack and crashes it with SIGSEGV. This is asymmetric with the iterative sibling path (append_awaited_by_for_thread), which already bounds its walk with MAX_ITERATIONS. This PR bounds the recursion with an explicit depth cap (MAX_TASK_AWAITED_BY_DEPTH, defined next to the existing MAX_ITERATIONS / MAX_SET_TABLE_SIZE / MAX_* constants in _remote_debugging.h). The depth is threaded through the existing generic processor/context callback via a small waiter_context_t { result, depth }, so the public process_task_and_waiters signature is unchanged (it stays a depth == 0 wrapper over the new process_task_and_waiters_impl). On overflow the code raises a RuntimeError through the module's existing set_exception_cause error path, matching how the module reports every other "corrupted remote memory" condition. A depth counter (rather than a visited-set) also covers a cyclic awaited_by graph from corrupted remote memory, since each recursion still increments the depth. The module already documents that the target's memory is untrusted input (debug_offsets_validation.h), so a debugger reading an attacker-controlled or merely deeply-nested target must not be crashable by the target's graph shape; bounding this traversal is consistent with the module's existing invariants. Adds test_async_deep_awaited_by_chain_is_bounded to Lib/test/test_external_inspection.py: it spawns a target with a deep linear awaited_by chain whose leaf is the running task and asserts that get_async_stack_trace() raises RuntimeError ("too deep or cyclic") instead of crashing. Verified that the pre-fix interpreter segfaults (SIGSEGV) on a deep chain while the patched interpreter raises a clean RuntimeError, and that a shallow chain still returns a stack trace normally (negative control). The existing asyncio stack-trace tests continue to pass. Closes #151535 This change was prepared with AI assistance; I have reviewed and verified the code, the reasoning, and the test myself. Issue: gh-151535

Open Graph Description: _remote_debugging.RemoteUnwinder.get_async_stack_trace() walks the target process's asyncio awaited_by graph with an unbounded three-function C recursion (process_task_and_waiters → process_tas...

X Description: _remote_debugging.RemoteUnwinder.get_async_stack_trace() walks the target process's asyncio awaited_by graph with an unbounded three-function C recursion (process_task_and_waiters → process...

Opengraph URL: https://github.com/python/cpython/pull/151536

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c2f248c7-72ce-1455-a168-d7f9c45063e9
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE7AE:23DB5F:B1B55F:DF7345:6B022305
html-safe-nonce02c4ad98098e5ff90eb880cfe157d14a043d48b12c6a50ef76420e53f41dce9b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0FFOjIzREI1RjpCMUI1NUY6REY3MzQ1OjZCMDIyMzA1IiwidmlzaXRvcl9pZCI6IjE1NTIzNzY3NDM2NTI4OTM0NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4e1f3886c6d0744ccd738b59268b1bc2703856fb98d96a99c2514b8edaaaa032
hovercard-subject-tagpull_request:3874203232
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/151536/files
twitter:imagehttps://avatars.githubusercontent.com/u/23011166?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/23011166?s=400&v=4
og:image:alt_remote_debugging.RemoteUnwinder.get_async_stack_trace() walks the target process's asyncio awaited_by graph with an unbounded three-function C recursion (process_task_and_waiters → process_tas...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/151536/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F151536%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F151536%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/151536/files
Reloadhttps://github.com/python/cpython/pull/151536/files
Reloadhttps://github.com/python/cpython/pull/151536/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
tonghuaroothttps://github.com/tonghuaroot
python:mainhttps://github.com/python/cpython/tree/main
tonghuaroot:gh-151535-bound-awaited-by-recursionhttps://github.com/tonghuaroot/cpython/tree/gh-151535-bound-awaited-by-recursion
Conversation 2 https://github.com/python/cpython/pull/151536
Commits 2 https://github.com/python/cpython/pull/151536/commits
Checks 50 https://github.com/python/cpython/pull/151536/checks
Files changed https://github.com/python/cpython/pull/151536/files
Please reload this pagehttps://github.com/python/cpython/pull/151536/files
gh-151535: Bound _remote_debugging asyncio awaited_by graph recursion https://github.com/python/cpython/pull/151536/files#top
Show all changes 2 commits https://github.com/python/cpython/pull/151536/files
67e7b05 gh-151535: Bound _remote_debugging asyncio awaited_by graph recursion tonghuaroot Jun 16, 2026 https://github.com/python/cpython/pull/151536/commits/67e7b05b9503cac5d32351c80047b5743dcd322c
dcd1db0 gh-151535: Walk awaited_by graph iteratively to avoid C stack overflow tonghuaroot Jun 16, 2026 https://github.com/python/cpython/pull/151536/commits/dcd1db0c5d6e68257328faf04dca19d49913c454
Clear filters https://github.com/python/cpython/pull/151536/files
Please reload this pagehttps://github.com/python/cpython/pull/151536/files
Please reload this pagehttps://github.com/python/cpython/pull/151536/files
test_external_inspection.py https://github.com/python/cpython/pull/151536/files#diff-e23d1425a6f43944cb282709edbeacfa2398f4cd4c109e59dd49366dac46f2d7
2026-06-15-10-08-29.gh-issue-151535.CIumHj.rst https://github.com/python/cpython/pull/151536/files#diff-a67fe04060e6837a38decff9d066109abe63f1855e754c6faa828fe4a55d5c61
_remote_debugging.h https://github.com/python/cpython/pull/151536/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
asyncio.c https://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
Lib/test/test_external_inspection.pyhttps://github.com/python/cpython/pull/151536/files#diff-e23d1425a6f43944cb282709edbeacfa2398f4cd4c109e59dd49366dac46f2d7
View file https://github.com/tonghuaroot/cpython/blob/dcd1db0c5d6e68257328faf04dca19d49913c454/Lib/test/test_external_inspection.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151536/{{ revealButtonHref }}
https://github.com/python/cpython/pull/151536/files#diff-e23d1425a6f43944cb282709edbeacfa2398f4cd4c109e59dd49366dac46f2d7
https://github.com/python/cpython/pull/151536/files#diff-e23d1425a6f43944cb282709edbeacfa2398f4cd4c109e59dd49366dac46f2d7
Misc/NEWS.d/next/Library/2026-06-15-10-08-29.gh-issue-151535.CIumHj.rsthttps://github.com/python/cpython/pull/151536/files#diff-a67fe04060e6837a38decff9d066109abe63f1855e754c6faa828fe4a55d5c61
View file https://github.com/tonghuaroot/cpython/blob/dcd1db0c5d6e68257328faf04dca19d49913c454/Misc/NEWS.d/next/Library/2026-06-15-10-08-29.gh-issue-151535.CIumHj.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151536/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L336
Modules/_remote_debugging/_remote_debugging.hhttps://github.com/python/cpython/pull/151536/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
View file https://github.com/tonghuaroot/cpython/blob/dcd1db0c5d6e68257328faf04dca19d49913c454/Modules/_remote_debugging/_remote_debugging.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151536/{{ revealButtonHref }}
https://github.com/python/cpython/pull/151536/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
https://github.com/python/cpython/pull/151536/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L336
Modules/_remote_debugging/asyncio.chttps://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
View file https://github.com/tonghuaroot/cpython/blob/dcd1db0c5d6e68257328faf04dca19d49913c454/Modules/_remote_debugging/asyncio.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151536/{{ revealButtonHref }}
https://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
https://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
https://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
https://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
https://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
https://github.com/python/cpython/pull/151536/files#diff-d3a9f5049ca6c549a4feb928b6d06a7dbce8486745bb06f6b8254cddce207e32
Please reload this pagehttps://github.com/python/cpython/pull/151536/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.