René's URL Explorer Experiment


Title: CPython 3.12 embedded in WeeChat causes segfault on subsequent calls to Py_EndInterpreter · Issue #116510 · python/cpython · GitHub

Open Graph Title: CPython 3.12 embedded in WeeChat causes segfault on subsequent calls to Py_EndInterpreter · Issue #116510 · python/cpython

X Title: CPython 3.12 embedded in WeeChat causes segfault on subsequent calls to Py_EndInterpreter · Issue #116510 · python/cpython

Description: Crash report What happened? WeeChat embeds CPython in order to run Python scripts inside WeeChat. It can load multiple scripts and they each get their own interpreter. When a script is loaded Py_NewInterpreter is called, and when it's un...

Open Graph Description: Crash report What happened? WeeChat embeds CPython in order to run Python scripts inside WeeChat. It can load multiple scripts and they each get their own interpreter. When a script is loaded Py_Ne...

X Description: Crash report What happened? WeeChat embeds CPython in order to run Python scripts inside WeeChat. It can load multiple scripts and they each get their own interpreter. When a script is loaded Py_Ne...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CPython 3.12 embedded in WeeChat causes segfault on subsequent calls to Py_EndInterpreter","articleBody":"# Crash report\r\n\r\n### What happened?\r\n\r\nWeeChat embeds CPython in order to run Python scripts inside WeeChat. It can load multiple scripts and they each get their own interpreter. When a script is loaded `Py_NewInterpreter` is called, and when it's unloaded `Py_EndInterpreter` is called.\r\n\r\nWith CPython 3.12 loading two scripts and then unloading them in the same order causes a segmentation fault. Interestingly, the segmentation fault doesn't happen if the script that was loaded last is unloaded first.\r\n\r\nI bisected this and found it was introduced in commit de64e7561680fdc5358001e9488091e75d4174a3. I also noticed that the crash doesn't occur in the main branch, and did another bisect and found it was fixed in commit 7a7bce5a0ab249407e866a1e955d21fa2b0c8506.\r\n\r\nThis issue seems similar to the one reported in #115649 which is also introduced by the same commit, but that one still crashes on the main branch (commit 735fc2cbbcf875c359021b5b2af7f4c29f4cf66d).\r\n\r\nI haven't been able to reproduce this outside of WeeChat unfortunately, but here is a backtrace from the crash with WeeChat, with commit de64e7561680fdc5358001e9488091e75d4174a3 of CPython and commit ec56a1103f47b15a641ff93528fd6f50025dd524 of WeeChat.\r\n\r\n```\r\nProgram terminated with signal SIGSEGV, Segmentation fault.\r\n#0  0x000074b5e5fd2700 in ?? ()\r\n[Current thread is 1 (Thread 0x74b5e7bec940 (LWP 1881931))]\r\n(gdb) bt\r\n#0  0x000074b5e5fd2700 in ?? ()\r\n#1  \u003csignal handler called\u003e\r\n#2  0x000074b5e64f9ddd in _PyGCHead_SET_PREV (prev=\u003coptimized out\u003e, gc=\u003coptimized out\u003e) at ./Include/internal/pycore_gc.h:74\r\n#3  _PyObject_GC_UNTRACK (op=0x74b5dfb746d0) at ./Include/internal/pycore_object.h:228\r\n#4  PyObject_GC_UnTrack (op_raw=op_raw@entry=0x74b5dfb746d0) at Modules/gcmodule.c:2241\r\n#5  0x000074b5e63c430c in module_dealloc (m=0x74b5dfb746d0) at Objects/moduleobject.c:672\r\n#6  0x000074b5e63c393d in Py_DECREF (op=\u003coptimized out\u003e) at ./Include/object.h:681\r\n#7  Py_XDECREF (op=\u003coptimized out\u003e) at ./Include/object.h:777\r\n#8  meth_dealloc (m=0x74b5dfb81210) at Objects/methodobject.c:170\r\n#9  0x000074b5e63b5d00 in Py_DECREF (op=0x74b5dfb81210) at ./Include/object.h:681\r\n#10 Py_XDECREF (op=0x74b5dfb81210) at ./Include/object.h:777\r\n#11 insertdict (interp=0x74b5e0e42010, mp=mp@entry=0x74b5df1d3d40, key=0x74b5dfb7db30, hash=\u003coptimized out\u003e, value=value@entry=0x74b5e6750240 \u003c_Py_NoneStruct\u003e) at Objects/dictobject.c:1304\r\n#12 0x000074b5e63b6107 in _PyDict_SetItem_Take2 (value=0x74b5e6750240 \u003c_Py_NoneStruct\u003e, key=\u003coptimized out\u003e, mp=0x74b5df1d3d40) at Objects/dictobject.c:1854\r\n#13 0x000074b5e63c5684 in _PyModule_ClearDict (d=0x74b5df1d3d40) at Objects/moduleobject.c:619\r\n#14 0x000074b5e63c5a6e in _PyModule_Clear (m=m@entry=0x74b5df1e12b0) at Objects/moduleobject.c:567\r\n#15 0x000074b5e64c884e in finalize_modules_clear_weaklist (verbose=0, weaklist=0x74b5dfbed080, interp=0x74b5e0e42010) at Python/pylifecycle.c:1491\r\n#16 finalize_modules (tstate=tstate@entry=0x74b5e0ea0400) at Python/pylifecycle.c:1574\r\n#17 0x000074b5e64cc476 in Py_EndInterpreter (tstate=0x74b5e0ea0400) at Python/pylifecycle.c:2137\r\n#18 0x000074b5e6a5bce6 in weechat_python_unload (script=0x5d9a7b80ee60) at /home/trygve/dev/weechat/src/plugins/python/weechat-python.c:947\r\n#19 0x000074b5e6a5bea6 in weechat_python_unload_all () at /home/trygve/dev/weechat/src/plugins/python/weechat-python.c:996\r\n#20 0x000074b5e7b81cea in plugin_script_end (weechat_plugin=0x5d9a7b29ad50, plugin_data=0x74b5e6a9e640 \u003cpython_data\u003e) at /home/trygve/dev/weechat/src/plugins/plugin-script.c:1841\r\n#21 0x000074b5e6a5d8c4 in weechat_plugin_end (plugin=0x5d9a7b29ad50) at /home/trygve/dev/weechat/src/plugins/python/weechat-python.c:1634\r\n#22 0x00005d9a78ed4c38 in plugin_unload (plugin=0x5d9a7b29ad50) at /home/trygve/dev/weechat/src/plugins/plugin.c:1261\r\n#23 0x00005d9a78ed4d9f in plugin_unload_all () at /home/trygve/dev/weechat/src/plugins/plugin.c:1313\r\n#24 0x00005d9a78ed50f8 in plugin_end () at /home/trygve/dev/weechat/src/plugins/plugin.c:1433\r\n#25 0x00005d9a78e04340 in weechat_end (gui_end_cb=0x5d9a78ecb8ae \u003cgui_main_end\u003e) at /home/trygve/dev/weechat/src/core/weechat.c:709\r\n#26 0x00005d9a78e03163 in main (argc=4, argv=0x7ffdb171c178) at /home/trygve/dev/weechat/src/gui/curses/normal/main.c:45\r\n```\r\n\r\nThis was produced by creating these two python scripts:\r\n\r\n`dummy1.py`:\r\n```python\r\nimport weechat\r\n\r\nif weechat.register(\"dummy1\", \"trygveaa\", \"0.1\", \"MIT\", \"Dummy script 1\", \"\", \"\"):\r\n    weechat.prnt(\"\", \"Loaded dummy script 1\")\r\n```\r\n\r\n`dummy2.py`\r\n```python\r\nimport weechat\r\n\r\nif weechat.register(\"dummy2\", \"trygveaa\", \"0.1\", \"MIT\", \"Dummy script 2\", \"\", \"\"):\r\n    weechat.prnt(\"\", \"Loaded dummy script 2\")\r\n```\r\n\r\nAnd then running `weechat -t -r '/script load dummy1.py; /script load dummy2.py; /quit'`.\r\n\r\nAlso, here is the issue report for WeeChat: https://github.com/weechat/weechat/issues/2046\r\n\r\nSince it's fixed in main it seems there won't be a problem with 3.13, but I wonder if the fix can be backported to 3.12?\r\n\r\n### CPython versions tested on:\r\n\r\n3.12, CPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n### Output from running 'python -VV' on the command line:\r\n\r\nPython 3.12.0a7+ (tags/v3.12.0a7-340-gde64e75616:de64e75616, Mar  8 2024, 19:43:39) [GCC 13.2.1 20230801]\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-124536\n* gh-124541\n* gh-124645\n* gh-124646\n* gh-124648\n* gh-124649\n* gh-124865\n* gh-125204\n* gh-125205\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/trygveaa","@type":"Person","name":"trygveaa"},"datePublished":"2024-03-08T19:12:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/116510/cpython/issues/116510"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:18d22843-1bd4-f4a7-105a-7dc04d06455e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC3EA:199660:AD3D32:F1DC3B:696A2846
html-safe-nonceb1de88baeb79e3acdaf4b22f3f8ad350fab5352108f5d12193e50b045752c1bc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0VBOjE5OTY2MDpBRDNEMzI6RjFEQzNCOjY5NkEyODQ2IiwidmlzaXRvcl9pZCI6IjY0MzQ2Mzc4NDYyMDYzNTk2MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac747052b0b27b8586a2ded1e1ee6e6e8ab1418d5fd8fb1eb9f5aaa1216041d66d
hovercard-subject-tagissue:2176624617
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/116510/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5300478a50df29a2b408f41bce6c3a0d8d8e9364eaddab1512ec0651f393d117/python/cpython/issues/116510
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5300478a50df29a2b408f41bce6c3a0d8d8e9364eaddab1512ec0651f393d117/python/cpython/issues/116510
og:image:altCrash report What happened? WeeChat embeds CPython in order to run Python scripts inside WeeChat. It can load multiple scripts and they each get their own interpreter. When a script is loaded Py_Ne...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametrygveaa
hostnamegithub.com
expected-hostnamegithub.com
Nonea1022f03e4f0d91ea173e4e5dac892c982e0588c62f1ce56121d755a320a3569
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
releasef472b8e6c7b3fdd5d0354972a3f4c516289bf0be
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/116510#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F116510
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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%2Fissues%2F116510
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%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/116510
Reloadhttps://github.com/python/cpython/issues/116510
Reloadhttps://github.com/python/cpython/issues/116510
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/116510
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k 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.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/116510
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 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/116510
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/116510
CPython 3.12 embedded in WeeChat causes segfault on subsequent calls to Py_EndInterpreterhttps://github.com/python/cpython/issues/116510#top
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%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/trygveaa
https://github.com/trygveaa
trygveaahttps://github.com/trygveaa
on Mar 8, 2024https://github.com/python/cpython/issues/116510#issue-2176624617
de64e75https://github.com/python/cpython/commit/de64e7561680fdc5358001e9488091e75d4174a3
7a7bce5https://github.com/python/cpython/commit/7a7bce5a0ab249407e866a1e955d21fa2b0c8506
#115649https://github.com/python/cpython/issues/115649
735fc2chttps://github.com/python/cpython/commit/735fc2cbbcf875c359021b5b2af7f4c29f4cf66d
de64e75https://github.com/python/cpython/commit/de64e7561680fdc5358001e9488091e75d4174a3
weechat/weechat#2046https://github.com/weechat/weechat/issues/2046
[3.12] gh-116510: Fix crash during sub-interpreter shutdown #124536https://github.com/python/cpython/pull/124536
[3.12] gh-116510: Fix a crash due to shared immortal interned strings. #124541https://github.com/python/cpython/pull/124541
gh-116510: Fix crash during sub-interpreter shutdown #124645https://github.com/python/cpython/pull/124645
gh-116510: Fix crash due to shared immortal interned strings. #124646https://github.com/python/cpython/pull/124646
[3.13] gh-116510: Fix crash due to shared immortal interned strings. (gh-124646) #124648https://github.com/python/cpython/pull/124648
[3.13] gh-116510: Fix crash during sub-interpreter shutdown (gh-124645) #124649https://github.com/python/cpython/pull/124649
gh-116510: Fix a Crash Due to Shared Immortal Interned Strings #124865https://github.com/python/cpython/pull/124865
[3.13] gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865) #125204https://github.com/python/cpython/pull/125204
[3.12] gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865) #125205https://github.com/python/cpython/pull/125205
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%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.