René's URL Explorer Experiment


Title: gh-149590: Remove faulthandler_traverse by armaan-v924 · Pull Request #150023 · python/cpython · GitHub

Open Graph Title: gh-149590: Remove faulthandler_traverse by armaan-v924 · Pull Request #150023 · python/cpython

X Title: gh-149590: Remove faulthandler_traverse by armaan-v924 · Pull Request #150023 · python/cpython

Description: tldr; faulthandler_traverse visits Python objects owned by _PyRuntime, not by the module instance. With multi-phase init allowing multiple module instances, each instance's GC traversal decrements gc_refs on the same runtime-owned objects, driving it negative when two instances are collected simultaneously. Cleanup is already handled well, traversal is redundant, and harmless with a single instantiation. Expanded Explanation: Author's note: This is my first foray into the CPython codebase. Would appreciate all the scrutiny :D RCA: BG: faulthandler uses multi-phase init, so deleting it from sys.modules and re-importing produces a second, independent module object. Both module objects are tracked by the garbage collector and both have md_state_traverse = faulthandler_traverse stored. subtract_refs iterates every object in the GC generation list. For each object it calls Py_TYPE(op)->tp_traverse — for module objects that's module_traverse in Objects/moduleobject.c module_traverse calls md_state_traverse (i.e. faulthandler_traverse) then visits md_dict faulthandler_traverse calls Py_VISIT(fatal_error.file)(expands to visit_decref(_PyRuntime.faulthandler.fatal_error.file)) With two module instances this runs twice; gc_refs on fatal_error.file (stderr, by default) is decremented twice But fatal_error.file's real refcount only has one reference from _PyRuntime; gc_refs goes negative → debug assertion fires, silent UAF in release Safety m_traverse exists to tell the GC about Python objects owned by per-module C state (md_state, allocated when m_size > 0). faulthandler has m_size = 0, so there is no per-module C state. fatal_error.file, thread.file, and user_signals[signum].file are all owned by _PyRuntime, not by any module instance. _PyRuntime is not a Python object and is never in containers, so its references are never passed to visit_decref, they contribute to ob_refcnt but are never subtracted, meaning gc_refs >= 1 after subtract_refs. GC will never mark these objects as unreachable regardless of whether the module traverse visits them. Cleanup is already handled correctly: faulthandler_disable() calls Py_CLEAR(fatal_error.file) (and equivalents), and _PyFaulthandler_Fini() calls faulthandler_disable() at shutdown. No GC involvement is needed. Functionality From main: After removal: Issue: gh-149590

Open Graph Description: tldr; faulthandler_traverse visits Python objects owned by _PyRuntime, not by the module instance. With multi-phase init allowing multiple module instances, each instance's GC traversal decreme...

X Description: tldr; faulthandler_traverse visits Python objects owned by _PyRuntime, not by the module instance. With multi-phase init allowing multiple module instances, each instance's GC traversal dec...

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

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:b3280dfb-bf58-28dd-3b6f-c5afe4d259e2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB822:1DC4CC:14EC5CB:1BDA8E2:6B01FEE9
html-safe-nonce86b74718e0795ef70187414a839dfdb304436ed099e4e3457e174a377d71bbfd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODIyOjFEQzRDQzoxNEVDNUNCOjFCREE4RTI6NkIwMUZFRTkiLCJ2aXNpdG9yX2lkIjoiMTg3Nzk3NTUyNTcxMzExNjkwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacc0b339c05fcc5dc858c3a3ba714b8692207f330afd57bab1c4787046a957ffdc
hovercard-subject-tagpull_request:3704274481
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/150023/files
twitter:imagehttps://avatars.githubusercontent.com/u/43391096?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/43391096?s=400&v=4
og:image:alttldr; faulthandler_traverse visits Python objects owned by _PyRuntime, not by the module instance. With multi-phase init allowing multiple module instances, each instance's GC traversal decreme...
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/150023/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F150023%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%2F150023%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/150023/files
Reloadhttps://github.com/python/cpython/pull/150023/files
Reloadhttps://github.com/python/cpython/pull/150023/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
JelleZijlstrahttps://github.com/JelleZijlstra
python:mainhttps://github.com/python/cpython/tree/main
armaan-v924:armaan/issue-149590-multi-instance-faulthandlerhttps://github.com/armaan-v924/cpython/tree/armaan/issue-149590-multi-instance-faulthandler
Conversation 12 https://github.com/python/cpython/pull/150023
Commits 3 https://github.com/python/cpython/pull/150023/commits
Checks 63 https://github.com/python/cpython/pull/150023/checks
Files changed https://github.com/python/cpython/pull/150023/files
Please reload this pagehttps://github.com/python/cpython/pull/150023/files
gh-149590: Remove faulthandler_traverse https://github.com/python/cpython/pull/150023/files#top
Show all changes 3 commits https://github.com/python/cpython/pull/150023/files
5441d5c Remove faulthandler_traverse armaan-v924 May 18, 2026 https://github.com/python/cpython/pull/150023/commits/5441d5c838978a253cae97fe3a8810e0b1fc6215
a8fab9f Added relevant news entry armaan-v924 May 18, 2026 https://github.com/python/cpython/pull/150023/commits/a8fab9ff3c6ade13b6ba764a0fd294170096bf58
dd3565e Updated NEWS entry to focus on user impact armaan-v924 May 18, 2026 https://github.com/python/cpython/pull/150023/commits/dd3565ef1d3ceae4f56e5f3c1b7142210af936f4
Clear filters https://github.com/python/cpython/pull/150023/files
Please reload this pagehttps://github.com/python/cpython/pull/150023/files
Please reload this pagehttps://github.com/python/cpython/pull/150023/files
2026-05-18-13-47-17.gh-issue-149590.IPBeQx.rst https://github.com/python/cpython/pull/150023/files#diff-14c70cfa3a35f922938b02548d17458b6c3ebefcb62e537aecbdf624ad5c6b83
faulthandler.c https://github.com/python/cpython/pull/150023/files#diff-b2263afa44dcc1317d50775651e27589b6f15fd858d1508e4d5dcc060ea4f991
Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-13-47-17.gh-issue-149590.IPBeQx.rsthttps://github.com/python/cpython/pull/150023/files#diff-14c70cfa3a35f922938b02548d17458b6c3ebefcb62e537aecbdf624ad5c6b83
View file https://github.com/armaan-v924/cpython/blob/dd3565ef1d3ceae4f56e5f3c1b7142210af936f4/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-13-47-17.gh-issue-149590.IPBeQx.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150023/{{ revealButtonHref }}
Modules/faulthandler.chttps://github.com/python/cpython/pull/150023/files#diff-b2263afa44dcc1317d50775651e27589b6f15fd858d1508e4d5dcc060ea4f991
View file https://github.com/armaan-v924/cpython/blob/dd3565ef1d3ceae4f56e5f3c1b7142210af936f4/Modules/faulthandler.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150023/{{ revealButtonHref }}
https://github.com/python/cpython/pull/150023/files#diff-b2263afa44dcc1317d50775651e27589b6f15fd858d1508e4d5dcc060ea4f991
https://github.com/python/cpython/pull/150023/files#diff-b2263afa44dcc1317d50775651e27589b6f15fd858d1508e4d5dcc060ea4f991
https://github.com/python/cpython/pull/150023/files#diff-b2263afa44dcc1317d50775651e27589b6f15fd858d1508e4d5dcc060ea4f991
https://github.com/python/cpython/pull/150023/files#diff-b2263afa44dcc1317d50775651e27589b6f15fd858d1508e4d5dcc060ea4f991
Please reload this pagehttps://github.com/python/cpython/pull/150023/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.