Title: Multithreaded subinterpreters can be running during finalization · Issue #126016 · python/cpython · GitHub
Open Graph Title: Multithreaded subinterpreters can be running during finalization · Issue #126016 · python/cpython
X Title: Multithreaded subinterpreters can be running during finalization · Issue #126016 · python/cpython
Description: Crash report What happened? (Found while investigating a fix for #125920.) Subinterpreters that are running in a different thread can still be running upon the finalization of the main interpreter, depending on what the thread was doing....
Open Graph Description: Crash report What happened? (Found while investigating a fix for #125920.) Subinterpreters that are running in a different thread can still be running upon the finalization of the main interpreter,...
X Description: Crash report What happened? (Found while investigating a fix for #125920.) Subinterpreters that are running in a different thread can still be running upon the finalization of the main interpreter,...
Opengraph URL: https://github.com/python/cpython/issues/126016
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Multithreaded subinterpreters can be running during finalization","articleBody":"# Crash report\n\n### What happened?\n\n(Found while investigating a fix for #125920.)\n\nSubinterpreters that are running in a different thread can still be running upon the finalization of the main interpreter, depending on what the thread was doing. Take the following script:\n\n```py\nfrom threading import Thread\nimport _interpreters\n\n\ndef silly():\n interp = _interpreters.create()\n _interpreters.run_string(interp, \"import time; time.sleep(100)\")\n\n\nif __name__ == \"__main__\":\n Thread(target=silly).start()\n```\n\nOn 3.13 and 3.14, killing the process with CTRL+C results in an assertion failure:\n\n```\npython: Python/pylifecycle.c:2480: finalize_subinterpreters: Assertion `!_PyInterpreterState_IsRunningMain(interp)' failed.\n```\n\nHowever, if the thread is daemon, then the interpreter fully segfaults:\n\n```py\nfrom threading import Thread\nimport _interpreters\n\n\ndef silly():\n interp = _interpreters.create()\n _interpreters.run_string(interp, \"import time; time.sleep(100)\")\n\n\nif __name__ == \"__main__\":\n Thread(target=silly, daemon=True).start()\n```\n\nI'm going to investigate possible fixes.\n\ncc @ericsnowcurrently\n\n### CPython versions tested on:\n\n3.13, CPython 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 --\u003e\n### Linked PRs\n* gh-126026\n* gh-139158\n* gh-139219\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ZeroIntensity","@type":"Person","name":"ZeroIntensity"},"datePublished":"2024-10-26T19:10:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/126016/cpython/issues/126016"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b52aa105-10cb-981b-b967-e84b313ae88b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DB0:2A6D10:326E406:41B987B:696B886A |
| html-safe-nonce | 462bebc342772a4d35b2b8f356dc2b411c0f223fe2cf232db3eb61221617f930 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REIwOjJBNkQxMDozMjZFNDA2OjQxQjk4N0I6Njk2Qjg4NkEiLCJ2aXNpdG9yX2lkIjoiMzc1NTcwNTg3MTM5NjIxMDc5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 32b2d92b2010543a86abe3f6628e2e67bd8c4dc6066b6aac32bfce74a801b506 |
| hovercard-subject-tag | issue:2616073322 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/126016/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2737f8175f0fbb16cb9342948565dbead65375e15175b3c4157d8f23333ed0fe/python/cpython/issues/126016 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2737f8175f0fbb16cb9342948565dbead65375e15175b3c4157d8f23333ed0fe/python/cpython/issues/126016 |
| og:image:alt | Crash report What happened? (Found while investigating a fix for #125920.) Subinterpreters that are running in a different thread can still be running upon the finalization of the main interpreter,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ZeroIntensity |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width