René's URL Explorer Experiment


Title: Extensions that raise exceptions in their `PyInit*` cause a crash in subinterpreters · Issue #144601 · python/cpython · GitHub

Open Graph Title: Extensions that raise exceptions in their `PyInit*` cause a crash in subinterpreters · Issue #144601 · python/cpython

X Title: Extensions that raise exceptions in their `PyInit*` cause a crash in subinterpreters · Issue #144601 · python/cpython

Description: Crash report What happened? I found this while investigating #138045. If a PyInit_ function raises an exception when imported from a subinterpreter, the process will crash. For example, if you modify xxsubtyppe.c to raise an exception in...

Open Graph Description: Crash report What happened? I found this while investigating #138045. If a PyInit_ function raises an exception when imported from a subinterpreter, the process will crash. For example, if you modi...

X Description: Crash report What happened? I found this while investigating #138045. If a PyInit_ function raises an exception when imported from a subinterpreter, the process will crash. For example, if you modi...

Opengraph URL: https://github.com/python/cpython/issues/144601

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Extensions that raise exceptions in their `PyInit*` cause a crash in subinterpreters","articleBody":"# Crash report\n\n### What happened?\n\nI found this while investigating #138045.\n\nIf a `PyInit_` function raises an exception when imported from a subinterpreter, the process will crash. For example, if you modify `xxsubtyppe.c` to raise an exception in its `PyInit` and then import it from a subinterpreter, you'll see a crash:\n\n```diff\ndiff --git a/Modules/xxsubtype.c b/Modules/xxsubtype.c\nindex a8a1417f40e..57a5ef75eb7 100644\n--- a/Modules/xxsubtype.c\n+++ b/Modules/xxsubtype.c\n@@ -324,5 +324,6 @@ static struct PyModuleDef xxsubtypemodule = {\n PyMODINIT_FUNC\n PyInit_xxsubtype(void)\n {\n-    return PyModuleDef_Init(&xxsubtypemodule);\n+    PyErr_SetString(PyExc_TypeError, \"whatever\");\n+    return NULL;\n }\n```\n\n```py\nfrom concurrent import interpreters\n\ninterp = interpreters.create()\ninterp.exec(\"import xxsubtype\")  # Crash!\n```\n\nThis isn't usually a problem for multi-phase extensions, because `PyModuleDef_Init` doesn't fail with an exception (except [sometimes on the free-threaded build](https://github.com/python/cpython/blob/d73634935cb9ce00a57dcacbd2e56371e4c18451/Objects/moduleobject.c#L128-L133), but that's rare), but this does happen for single-phase extensions. Single-phase extension modules do not support loading in subinterpreters, but attempting to load them from a subinterpreter should raise an exception rather than crash the interpreter.\n\nI believe the problem lies here:\n\nhttps://github.com/python/cpython/blob/d73634935cb9ce00a57dcacbd2e56371e4c18451/Python/import.c#L2178-L2196\n\nThe exception object raised by the `PyInit_` function is always owned by the main interpreter, but the exception is raised from the subinterpreter, which breaks things. There's not a clean way to raise the exception in the calling interpreter, so I think the best solution is to print the exception as unraisable in the main interpreter, and then raise some sort of blanket exception in the calling interpreter. \n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-144602\n* gh-144633\n* gh-144769\n* gh-144877\n* gh-144880\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/ZeroIntensity","@type":"Person","name":"ZeroIntensity"},"datePublished":"2026-02-08T17:23:07Z","url":"https://github.com/python/cpython/issues/144601"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b1a39092-ee8a-faac-33bf-e0a04c730e26
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD480:3FDF0C:587927:7638CB:6B003122
html-safe-nonced6ee91670d2e9caf55a44ec156498f9d39b8f961d9c8a5db56b05f9daf8046c0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDgwOjNGREYwQzo1ODc5Mjc6NzYzOENCOjZCMDAzMTIyIiwidmlzaXRvcl9pZCI6IjkzMjM4NDMyODg0NTg5ODAxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac116fe310825ce0eb3d9e0e5a309c3d374271af27078a4ba151098442c4fc8c21
hovercard-subject-tagissue:3913152291
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/144601/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c8d8fe806a135bbd01107e4d949569769a40c972213499af44218bbcdb5783a6/python/cpython/issues/144601
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c8d8fe806a135bbd01107e4d949569769a40c972213499af44218bbcdb5783a6/python/cpython/issues/144601
og:image:altCrash report What happened? I found this while investigating #138045. If a PyInit_ function raises an exception when imported from a subinterpreter, the process will crash. For example, if you modi...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameZeroIntensity
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/144601#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F144601
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%2Fissues%2F144601
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/144601
Reloadhttps://github.com/python/cpython/issues/144601
Reloadhttps://github.com/python/cpython/issues/144601
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
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/144601
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/144601
Extensions that raise exceptions in their PyInit* cause a crash in subinterpretershttps://github.com/python/cpython/issues/144601#top
https://github.com/ZeroIntensity
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-subinterpretershttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-subinterpreters%22
type-crashA hard crash of the interpreter, possibly with a core dumphttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-crash%22
https://github.com/ZeroIntensity
ZeroIntensityhttps://github.com/ZeroIntensity
on Feb 8, 2026https://github.com/python/cpython/issues/144601#issue-3913152291
#138045https://github.com/python/cpython/issues/138045
sometimes on the free-threaded buildhttps://github.com/python/cpython/blob/d73634935cb9ce00a57dcacbd2e56371e4c18451/Objects/moduleobject.c#L128-L133
cpython/Python/import.chttps://github.com/python/cpython/blob/d73634935cb9ce00a57dcacbd2e56371e4c18451/Python/import.c#L2178-L2196
d736349https://github.com/python/cpython/commit/d73634935cb9ce00a57dcacbd2e56371e4c18451
gh-144601: Avoid sharing exception objects raised in a PyInit function across multiple interpreters #144602https://github.com/python/cpython/pull/144602
[3.14] gh-144601: Avoid sharing exception objects raised in a PyInit function across multiple interpreters (GH-144602) #144633https://github.com/python/cpython/pull/144633
[3.14] gh-144601: Use _testmultiphase instead of _testsinglephase in test_importlib #144769https://github.com/python/cpython/pull/144769
[3.13] gh-144601: Use _testmultiphase instead of _testsinglephase in test_importlib (GH-144769) #144877https://github.com/python/cpython/pull/144877
[3.13] gh-144601: Avoid sharing exception objects raised in a PyInit function across multiple interpreters (GH-144602) #144880https://github.com/python/cpython/pull/144880
ZeroIntensityhttps://github.com/ZeroIntensity
on Feb 8, 2026https://github.com/python/cpython/issues/144601#event-22624971279
ZeroIntensityhttps://github.com/ZeroIntensity
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-crashA hard crash of the interpreter, possibly with a core dumphttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-crash%22
topic-subinterpretershttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-subinterpreters%22
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
on Feb 8, 2026https://github.com/python/cpython/issues/144601#event-22624971447
github-project-automationhttps://github.com/apps/github-project-automation
Subinterpretershttps://github.com/orgs/python/projects/3
on Feb 8, 2026https://github.com/python/cpython/issues/144601
github-project-automationhttps://github.com/apps/github-project-automation
Subinterpretershttps://github.com/orgs/python/projects/3
on Feb 8, 2026https://github.com/python/cpython/issues/144601#event-22624972451
encukouhttps://github.com/encukou
on Feb 9, 2026https://github.com/python/cpython/issues/144601#event-22648267899
gh-144601: Avoid sharing exception objects raised in a `PyInit` funct…https://github.com/python/cpython/commit/fd6b639a49dd1143c6fd8729fc49f17b3114a965
gh-144601https://github.com/python/cpython/issues/144601
fd6b639https://github.com/python/cpython/commit/fd6b639a49dd1143c6fd8729fc49f17b3114a965
miss-islingtonhttps://github.com/miss-islington
on Feb 9, 2026https://github.com/python/cpython/issues/144601#event-22648270955
pythongh-144601: Avoid sharing exception objects raised in a `PyInit`…https://github.com/miss-islington/cpython/commit/7725c61b5d11d827af35536225559a48bf040cab
pythongh-144601https://github.com/python/cpython/issues/144601
7725c61https://github.com/miss-islington/cpython/commit/7725c61b5d11d827af35536225559a48bf040cab
https://github.com/jan-hasse
jan-hassehttps://github.com/jan-hasse
on Feb 10, 2026https://github.com/python/cpython/issues/144601#issuecomment-3877654313
#142979https://github.com/python/cpython/pull/142979
https://github.com/ZeroIntensity
ZeroIntensityhttps://github.com/ZeroIntensity
on Feb 10, 2026https://github.com/python/cpython/issues/144601#issuecomment-3877696360
#142979https://github.com/python/cpython/pull/142979
thunder-codinghttps://github.com/thunder-coding
on Feb 15, 2026https://github.com/python/cpython/issues/144601#event-22797352387
pythongh-144601: Avoid sharing exception objects raised in a `PyInit`…https://github.com/thunder-coding/cpython/commit/bf9df37be41120d16631547adb671c3f3e04f233
pythongh-144601https://github.com/python/cpython/issues/144601
bf9df37https://github.com/thunder-coding/cpython/commit/bf9df37be41120d16631547adb671c3f3e04f233
encukouhttps://github.com/encukou
on Feb 16, 2026https://github.com/python/cpython/issues/144601#event-22824353162
[3.14] gh-144601: Use `_testmultiphase` instead of `_testsinglephase`…https://github.com/python/cpython/commit/d1486623263adea6a5138453bacad36a50c14e95
gh-144601https://github.com/python/cpython/issues/144601
d148662https://github.com/python/cpython/commit/d1486623263adea6a5138453bacad36a50c14e95
miss-islingtonhttps://github.com/miss-islington
on Feb 16, 2026https://github.com/python/cpython/issues/144601#event-22824355342
[3.14] pythongh-144601: Use `_testmultiphase` instead of `_testsingle…https://github.com/miss-islington/cpython/commit/a48159fd79117c128fdb643881a601680be38136
pythongh-144601https://github.com/python/cpython/issues/144601
a48159fhttps://github.com/miss-islington/cpython/commit/a48159fd79117c128fdb643881a601680be38136
ZeroIntensityhttps://github.com/ZeroIntensity
on Feb 16, 2026https://github.com/python/cpython/issues/144601#event-22828190524
[3.13] gh-144601: Use `_testmultiphase` instead of `_testsinglephase`…https://github.com/python/cpython/commit/e701a5cb181683db247d5c9533e911d2af72e2a8
gh-144601https://github.com/python/cpython/issues/144601
e701a5chttps://github.com/python/cpython/commit/e701a5cb181683db247d5c9533e911d2af72e2a8
[3.14] gh-144601: Avoid sharing exception objects raised in a `PyInit…https://github.com/python/cpython/commit/907958c4ba3f310d18810f7132f1ecd6798dd5c5
gh-144601https://github.com/python/cpython/issues/144601
907958chttps://github.com/python/cpython/commit/907958c4ba3f310d18810f7132f1ecd6798dd5c5
[3.13] pythongh-144601: Avoid sharing exception objects raised in a `…https://github.com/ZeroIntensity/cpython/commit/1b2c2a4dfbf15fc912d4009f3175e3b81ff70c3a
pythongh-144601https://github.com/python/cpython/issues/144601
1b2c2a4https://github.com/ZeroIntensity/cpython/commit/1b2c2a4dfbf15fc912d4009f3175e3b81ff70c3a
[3.13] pythongh-144601: Avoid sharing exception objects raised in a `…https://github.com/ZeroIntensity/cpython/commit/b00f9b06a81b6850300f783270072e45cc2b5589
pythongh-144601https://github.com/python/cpython/issues/144601
b00f9b0https://github.com/ZeroIntensity/cpython/commit/b00f9b06a81b6850300f783270072e45cc2b5589
[3.13] gh-144601: Avoid sharing exception objects raised in a `PyInit…https://github.com/python/cpython/commit/9314ec23a6b22758ecc0f43709b9fc49b253fb90
gh-144601https://github.com/python/cpython/issues/144601
9314ec2https://github.com/python/cpython/commit/9314ec23a6b22758ecc0f43709b9fc49b253fb90
ZeroIntensityhttps://github.com/ZeroIntensity
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Feb 16, 2026https://github.com/python/cpython/issues/144601#event-22830933202
github-project-automationhttps://github.com/apps/github-project-automation
Subinterpretershttps://github.com/orgs/python/projects/3
on Feb 16, 2026https://github.com/python/cpython/issues/144601
ljfphttps://github.com/ljfp
on Apr 25, 2026https://github.com/python/cpython/issues/144601#event-24868313841
pythongh-144601: Avoid sharing exception objects raised in a `PyInit`…https://github.com/ljfp/cpython/commit/864dfa3126660a14965b6609d0da8c07824ff06d
pythongh-144601https://github.com/python/cpython/issues/144601
864dfa3https://github.com/ljfp/cpython/commit/864dfa3126660a14965b6609d0da8c07824ff06d
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/144601
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/144601
ZeroIntensityhttps://github.com/ZeroIntensity
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-subinterpretershttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-subinterpreters%22
type-crashA hard crash of the interpreter, possibly with a core dumphttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-crash%22
Subinterpretershttps://github.com/orgs/python/projects/3
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.