René's URL Explorer Experiment


Title: gh-151842: Make _PyXI_FreeExcInfo NULL-safe to fix crash on capture_exception() OOM (OOM-0031) by amruthamodela06 · Pull Request #151843 · python/cpython · GitHub

Open Graph Title: gh-151842: Make _PyXI_FreeExcInfo NULL-safe to fix crash on capture_exception() OOM (OOM-0031) by amruthamodela06 · Pull Request #151843 · python/cpython

X Title: gh-151842: Make _PyXI_FreeExcInfo NULL-safe to fix crash on capture_exception() OOM (OOM-0031) by amruthamodela06 · Pull Request #151843 · python/cpython

Description: Closes #151842 Summary _interpreters.capture_exception() builds a _PyXI_excinfo via _PyXI_NewExcInfo(). Under memory pressure that allocation can fail and return NULL. The cleanup path in _interpreters_capture_exception_impl (Modules/_interpretersmodule.c:1544) then unconditionally calls _PyXI_FreeExcInfo(info) with info == NULL. _PyXI_FreeExcInfo has no NULL guard, so _PyXI_excinfo_clear → _excinfo_clear_type dereferences &NULL->type (offset 0) at Python/crossinterp.c:1319 → SIGSEGV. This reproduces on all build configurations (a NULL dereference, not a debug-only assert). Part of #151763 (OOM umbrella, OOM-0031). Reproducer import faulthandler, _interpreters faulthandler.enable() from _testcapi import set_nomemory, remove_mem_hooks for start in range(0, 40): try: set_nomemory(start, 0) try: _interpreters.capture_exception(Exception()) finally: remove_mem_hooks() except BaseException: pass finally: try: remove_mem_hooks() except Exception: pass Backtrace #0 _excinfo_clear_type Python/crossinterp.c:1319 # info == 0x0 -> offset-0 deref #1 _PyXI_excinfo_clear Python/crossinterp.c:1374 #2 _PyXI_FreeExcInfo Python/crossinterp.c:1712 # called with info == NULL, no guard #3 _interpreters_capture_exception_impl Modules/_interpretersmodule.c:1544 Fix Make _PyXI_FreeExcInfo NULL-safe, matching the surrounding PyMem_RawFree(NULL) idiom (and Py_XDECREF, free(), etc.). This is more defensive than guarding only the one call site, since _PyXI_FreeExcInfo is part of the cross-interpreter exception ABI and any future caller would otherwise have the same hazard. void _PyXI_FreeExcInfo(_PyXI_excinfo *info) { if (info == NULL) { return; } _PyXI_excinfo_clear(info); PyMem_RawFree(info); } Verification test_interpreters passes on the rebuilt binary (no regression in the success path). Per the discussion in #151773 (same umbrella), no OOM-injection regression test is added — those tests rely on internal allocation counts that need re-tuning across implementation changes. The fix should be verified by running the reproducer on a debug+ASan build. Issue: gh-151842

Open Graph Description: Closes #151842 Summary _interpreters.capture_exception() builds a _PyXI_excinfo via _PyXI_NewExcInfo(). Under memory pressure that allocation can fail and return NULL. The cleanup path in _interpre...

X Description: Closes #151842 Summary _interpreters.capture_exception() builds a _PyXI_excinfo via _PyXI_NewExcInfo(). Under memory pressure that allocation can fail and return NULL. The cleanup path in _interpre...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:cabc4e64-764e-1d9c-02c9-d17c74ac0211
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9250:6E56C:B45B2D:F08599:6A54055D
html-safe-noncef17e951c26d66ca53517cb08c3e405eefb5df7c2bbe48dfc23fec42b4d220d3c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjUwOjZFNTZDOkI0NUIyRDpGMDg1OTk6NkE1NDA1NUQiLCJ2aXNpdG9yX2lkIjoiNzQ3NzA3NzA3MjM5NTEwOTcyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac38037c0585c6170b8da75e407f3772dec08a462a91e5809dd554d0bade7952b9
hovercard-subject-tagpull_request:3906743759
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/151843/files
twitter:imagehttps://avatars.githubusercontent.com/u/213800128?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/213800128?s=400&v=4
og:image:altCloses #151842 Summary _interpreters.capture_exception() builds a _PyXI_excinfo via _PyXI_NewExcInfo(). Under memory pressure that allocation can fail and return NULL. The cleanup path in _interpre...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/151843/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F151843%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F151843%2Ffiles
Sign up https://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/151843/files
Reloadhttps://github.com/python/cpython/pull/151843/files
Reloadhttps://github.com/python/cpython/pull/151843/files
Please reload this pagehttps://github.com/python/cpython/pull/151843/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/151843/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
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
ZeroIntensityhttps://github.com/ZeroIntensity
python:mainhttps://github.com/python/cpython/tree/main
amruthamodela06:fix-pyxi-freeexcinfo-null-guardhttps://github.com/amruthamodela06/cpython/tree/fix-pyxi-freeexcinfo-null-guard
Conversation 22 https://github.com/python/cpython/pull/151843
Commits 4 https://github.com/python/cpython/pull/151843/commits
Checks 72 https://github.com/python/cpython/pull/151843/checks
Files changed https://github.com/python/cpython/pull/151843/files
Please reload this pagehttps://github.com/python/cpython/pull/151843/files
gh-151842: Make _PyXI_FreeExcInfo NULL-safe to fix crash on capture_exception() OOM (OOM-0031) https://github.com/python/cpython/pull/151843/files#top
Show all changes 4 commits https://github.com/python/cpython/pull/151843/files
57a99d4 gh-151842: Make _PyXI_FreeExcInfo NULL-safe to fix crash on capture_e… amruthamodela06 Jun 21, 2026 https://github.com/python/cpython/pull/151843/commits/57a99d45c085da21646672fcc1e095e16d2c518e
7d517f5 Fix NEWS rst: use inline code instead of :func: for internal _interpr… amruthamodela06 Jun 21, 2026 https://github.com/python/cpython/pull/151843/commits/7d517f56537386949cffc97f0e95ffd93c07e501
48c87aa Merge branch 'main' into fix-pyxi-freeexcinfo-null-guard amruthamodela06 Jun 23, 2026 https://github.com/python/cpython/pull/151843/commits/48c87aa134ede798336f30c4aaaee93d52428660
e4f031f Address review: guard call site, raise MemoryError in _PyXI_NewExcInf… amruthamodela06 Jun 23, 2026 https://github.com/python/cpython/pull/151843/commits/e4f031f54e64da0b95e3e2a4c82f85249f76e595
Clear filters https://github.com/python/cpython/pull/151843/files
Please reload this pagehttps://github.com/python/cpython/pull/151843/files
Please reload this pagehttps://github.com/python/cpython/pull/151843/files
2026-06-30-13-00-00.gh-issue-151842.OOM31g.rst https://github.com/python/cpython/pull/151843/files#diff-56eca39bd9dad37eeadfe513f978cac33a559ef68ad4780725a0533da2fb2b1b
_interpretersmodule.c https://github.com/python/cpython/pull/151843/files#diff-a5f60f3fb5ce69862b5b8e5668713db4e14715bec8c7a6b1f10e47b7d4517543
crossinterp.c https://github.com/python/cpython/pull/151843/files#diff-88c171bf6a3ab394012cb7af2d9929543d379573ff46279de7ad38d4e7a12c54
Misc/NEWS.d/next/Library/2026-06-30-13-00-00.gh-issue-151842.OOM31g.rsthttps://github.com/python/cpython/pull/151843/files#diff-56eca39bd9dad37eeadfe513f978cac33a559ef68ad4780725a0533da2fb2b1b
View file https://github.com/amruthamodela06/cpython/blob/e4f031f54e64da0b95e3e2a4c82f85249f76e595/Misc/NEWS.d/next/Library/2026-06-30-13-00-00.gh-issue-151842.OOM31g.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151843/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L349
Modules/_interpretersmodule.chttps://github.com/python/cpython/pull/151843/files#diff-a5f60f3fb5ce69862b5b8e5668713db4e14715bec8c7a6b1f10e47b7d4517543
View file https://github.com/amruthamodela06/cpython/blob/e4f031f54e64da0b95e3e2a4c82f85249f76e595/Modules/_interpretersmodule.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151843/{{ revealButtonHref }}
https://github.com/python/cpython/pull/151843/files#diff-a5f60f3fb5ce69862b5b8e5668713db4e14715bec8c7a6b1f10e47b7d4517543
https://github.com/python/cpython/pull/151843/files#diff-a5f60f3fb5ce69862b5b8e5668713db4e14715bec8c7a6b1f10e47b7d4517543
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L341
Python/crossinterp.chttps://github.com/python/cpython/pull/151843/files#diff-88c171bf6a3ab394012cb7af2d9929543d379573ff46279de7ad38d4e7a12c54
View file https://github.com/amruthamodela06/cpython/blob/e4f031f54e64da0b95e3e2a4c82f85249f76e595/Python/crossinterp.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151843/{{ revealButtonHref }}
https://github.com/python/cpython/pull/151843/files#diff-88c171bf6a3ab394012cb7af2d9929543d379573ff46279de7ad38d4e7a12c54
https://github.com/python/cpython/pull/151843/files#diff-88c171bf6a3ab394012cb7af2d9929543d379573ff46279de7ad38d4e7a12c54
https://github.com/python/cpython/pull/151843/files#diff-88c171bf6a3ab394012cb7af2d9929543d379573ff46279de7ad38d4e7a12c54
Please reload this pagehttps://github.com/python/cpython/pull/151843/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.