Title: [subinterpreters] Refleaks on Windows Under Specific Conditions · Issue #117936 · python/cpython · GitHub
Open Graph Title: [subinterpreters] Refleaks on Windows Under Specific Conditions · Issue #117936 · python/cpython
X Title: [subinterpreters] Refleaks on Windows Under Specific Conditions · Issue #117936 · python/cpython
Description: Bug report Bug description: One of my recent PRs, gh-117662, led to one of the Windows refleak buildbots failing1. I'm fairly confident the PR revealed an existing source of refleaks (albeit an unlikely one), rather that introducing new ...
Open Graph Description: Bug report Bug description: One of my recent PRs, gh-117662, led to one of the Windows refleak buildbots failing1. I'm fairly confident the PR revealed an existing source of refleaks (albeit an unl...
X Description: Bug report Bug description: One of my recent PRs, gh-117662, led to one of the Windows refleak buildbots failing1. I'm fairly confident the PR revealed an existing source of refleaks (albeit an...
Opengraph URL: https://github.com/python/cpython/issues/117936
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[subinterpreters] Refleaks on Windows Under Specific Conditions","articleBody":"# Bug report\n\n### Bug description:\n\nOne of my recent PRs, gh-117662, led to one of the Windows refleak buildbots failing[^1]. I'm fairly confident the PR revealed an existing source of refleaks (albeit an unlikely one), rather that introducing new leaks. I have resolved the failures with gh-117913, but the underlying potential source of refleaks remains.\n\n[^1]: https://buildbot.python.org/all/#/builders/920/builds/733\n\nI've been able to reproduce the leak conditions, but only on Windows (for now?). The following conditions are necessary:\n\n* interpreter created using a config with `check_multi_interp_extensions=False` (e.g. \"legacy\")\n* interpreter imports test.support.os_helper\n\n```python\ntry:\n import _interpreters\nexcept ModuleNotFoundError:\n import _xxsubinterpreters as _interpreters\nconfig = _interpreters.new_config('legacy') # critically, check_multi_interp_extensions=False\ninterpid = _interpreters.create(config)\n_interpreters.exec(interpid, 'import test.support.os_helper')\n_interpreters.destroy(interpid)\n# leaks a bunch of objects\n```\n\nWhen the bug is triggered, around 190 objects are leaked. At first I thought this was interpreter finalization failing silently, but now I think it is something else.\n\nI suspect the underlying problem relates to legacy extension modules. In the specific example above, I'm pretty sure the `_ctypes` module is leaking and ~190 is how many objects it holds, directly or indirectly. The main clue there is that, when I run `./python -v ...`, the `_ctypes` module is never noted as destroyed, whereas all other modules are. As to test.support.os_helper, `_ctypes` is one of the modules that gets indirectly imported. All that said, I haven't been able to reproduce the leak if the subinterpreter above imports `_ctypes` instead.\n\nWhy did we only see this on Windows? The only clue I can think of is that on Windows stdlib extension modules are all turned into builtin modules, IIRC. The logic of the `check_multi_interp_extensions` check (via `_PyImport_CheckSubinterpIncompatibleExtensionAllowed()` in Python/import.c) is specific to extension modules, not builtin modules.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nWindows","author":{"url":"https://github.com/ericsnowcurrently","@type":"Person","name":"ericsnowcurrently"},"datePublished":"2024-04-16T15:51:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/117936/cpython/issues/117936"}
| 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:e6a2d864-632e-b125-1357-215cd871ece5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E596:2FE5A8:1FBD56:2A6699:696B629D |
| html-safe-nonce | 49d0629de6f090096987c40e563ecdbcb9c619693110503c5326672167ed67c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTk2OjJGRTVBODoxRkJENTY6MkE2Njk5OjY5NkI2MjlEIiwidmlzaXRvcl9pZCI6IjI5Njg2NDkzNjkxOTI3MTkwMDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 999a91166afa9d84f10d6cc8bc5348b137b61fdb60d5460deab7b3a0841e9b9c |
| hovercard-subject-tag | issue:2246386546 |
| 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/117936/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cd032880b4ead231b82515ae22b400f7527360ebade51c2bd77d16d21b233b49/python/cpython/issues/117936 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cd032880b4ead231b82515ae22b400f7527360ebade51c2bd77d16d21b233b49/python/cpython/issues/117936 |
| og:image:alt | Bug report Bug description: One of my recent PRs, gh-117662, led to one of the Windows refleak buildbots failing1. I'm fairly confident the PR revealed an existing source of refleaks (albeit an unl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ericsnowcurrently |
| 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