Title: sys.remote_exec() is unable to find writable memory when libpython got deleted/replaced on disk · Issue #151029 · python/cpython · GitHub
Open Graph Title: sys.remote_exec() is unable to find writable memory when libpython got deleted/replaced on disk · Issue #151029 · python/cpython
X Title: sys.remote_exec() is unable to find writable memory when libpython got deleted/replaced on disk · Issue #151029 · python/cpython
Description: Bug report Bug description: The current happy path sys.remote_exec() looks at a remote PID's /proc/
Open Graph Description: Bug report Bug description: The current happy path sys.remote_exec() looks at a remote PID's /proc/
X Description: Bug report Bug description: The current happy path sys.remote_exec() looks at a remote PID's /proc/<pid>/maps, which allows it to find libpython on disk. Reading the libpython shared libr...
Opengraph URL: https://github.com/python/cpython/issues/151029
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sys.remote_exec() is unable to find writable memory when libpython got deleted/replaced on disk","articleBody":"# Bug report\n\n### Bug description:\n\n### The current happy path\n`sys.remote_exec()` looks at a remote PID's `/proc/\u003cpid\u003e/maps`, which allows it to find `libpython` on disk. Reading the `libpython` shared library file allows `sys.remote_exec()` to find the `.PyRuntime` section, which includes the debug offsets that point at the `remote_debugger_support.debugger_script_path[]` location where the debugger script path can be written to. The remote interpreter then finds the remotely injected update and does its thing to execute it.\n\n### The failure mode\nIn the case where `/proc/\u003cpid\u003e/maps` points at a libpython that got deleted from disk or replaced with a new file, this process fails early. CPython normally does not make any guarantees for such a case, but in this particular scenario we should be able to recover.\n\n### Why this is important to fix\nOn Linux in particular, in server environments scheduled package updates will include Python interpreter updates. When this happens, a long-running server process is now undebuggable. `sys.remote_exec()` is supposed to handle this very situation: allowing to debug a process without the need to kill it first.\n\nThe compatibility area between the `sys.remote_exec()` debugger and the debugged remote process is minimal: as long as both are the same minor version of Python (i.e. 3.14.x ←→ 3.14.x), the debug offsets structure will be parseable on both ends. ABI compatibility guarantees that no breaking changes for this use case will occur between bugfix releases within a minor release.\n\n### Suggested fix scope\nSince this is mostly important for centrally managed server scenarios, I suggest we address Linux first here and decide on other platforms after this succeeds.\n\nAs for the approach: even in the case of `/proc/\u003cpid\u003e/maps` pointing at a deleted file, it is also listing the memory location where that file was loaded. We can read the same information from memory then. Of course, file segments/sections are gone at this point, so it's a bit more of an involved process. But this will be a path taken only in the case when the file no longer exists on disk.\n\nAn alternative approach could be to try to dig out the inode of the now-deleted file and read the unlinked file that way. But this requires superuser privileges, so it's out of scope for `sys.remote_exec()`.\n\n### How to test this\nUsing `LD_LIBRARY_PATH=`, we can run a Python interpreter in such a way that it will pick up `libpython` from a copy in a temporary directory. Then the test will delete that copy, recreating our failure mode.\n\n### What about statically built Python?\nThis solution should also work for static builds. Instead of looking at `libpython`, we'd be looking at a deleted executable.\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-151032\n* gh-152443\n* gh-152464\n* gh-152653\n* gh-152665\n* gh-152669\n* gh-152670\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ambv","@type":"Person","name":"ambv"},"datePublished":"2026-06-06T17:23:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/151029/cpython/issues/151029"}
| 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:e728f329-576d-a14f-18d4-5963d879ee69 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D40:15E981:4C6512:699F3C:6A51208C |
| html-safe-nonce | b73f23eec233a0105d4f0099411e9e1bf7130e7754d4ff44a212f172e45911c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDQwOjE1RTk4MTo0QzY1MTI6Njk5RjNDOjZBNTEyMDhDIiwidmlzaXRvcl9pZCI6Ijc0ODc4NDM3MDA3MDc1MDAxNzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 21382e6af8ff3941d05defe898a05fb5c9e43ccb59c076af065d7d798f3566bf |
| hovercard-subject-tag | issue:4604464503 |
| 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/151029/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e9ec57f7809eba0401910dc57fbedc1f211a6507923c5dc0db3859fd6a1cc18a/python/cpython/issues/151029 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e9ec57f7809eba0401910dc57fbedc1f211a6507923c5dc0db3859fd6a1cc18a/python/cpython/issues/151029 |
| og:image:alt | Bug report Bug description: The current happy path sys.remote_exec() looks at a remote PID's /proc/ |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ambv |
| hostname | github.com |
| expected-hostname | github.com |
| None | 689b683944b0d7f015d0e776452c970832fa81b82dc15284469b556ecced715b |
| 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 | 942b51ed3bd5feee3d5e2719f890a5fe286edbbb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width