Title: `_remote_debugging`: raising `Invalid bytes length` on codeobjects with linetable > 4096 · Issue #151022 · python/cpython · GitHub
Open Graph Title: `_remote_debugging`: raising `Invalid bytes length` on codeobjects with linetable > 4096 · Issue #151022 · python/cpython
X Title: `_remote_debugging`: raising `Invalid bytes length` on codeobjects with linetable > 4096 · Issue #151022 · python/cpython
Description: Bug report Bug description: I've reproduced the issue reported in https://discuss.python.org/t/tachyon-97-error-rate/107619 The issue is caused by: cpython/Modules/_remote_debugging/code_objects.c Lines 389 to 390 in 884ac3e linetable = ...
Open Graph Description: Bug report Bug description: I've reproduced the issue reported in https://discuss.python.org/t/tachyon-97-error-rate/107619 The issue is caused by: cpython/Modules/_remote_debugging/code_objects.c ...
X Description: Bug report Bug description: I've reproduced the issue reported in https://discuss.python.org/t/tachyon-97-error-rate/107619 The issue is caused by: cpython/Modules/_remote_debugging/code_object...
Opengraph URL: https://github.com/python/cpython/issues/151022
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_remote_debugging`: raising `Invalid bytes length` on codeobjects with linetable > 4096","articleBody":"# Bug report\n\n### Bug description:\n\nI've reproduced the issue reported in https://discuss.python.org/t/tachyon-97-error-rate/107619 \n\nThe issue is caused by:\n\nhttps://github.com/python/cpython/blob/884ac3e3ec02347301939ff1f124972d4973f015/Modules/_remote_debugging/code_objects.c#L389-L390\n\nThe linetable for `HttpCli.tx_browser` and `HttpCli.run` is above 4096:\n\n```bash\n2026-06-06T17:13:54.694708000+0200 maurycy@gimel /Users/maurycy/work/cpython (main fded34d*?) % uv run linetable_dist.py ~/Desktop/copyparty\nobjects=3472 median=51 max=19536 >4096=7\n 19536 AuthSrv._reload /Users/maurycy/Desktop/copyparty/copyparty/authsrv.py:1762\n 10640 HttpCli.tx_browser /Users/maurycy/Desktop/copyparty/copyparty/httpcli.py:6749\n 9131 HttpCli.run /Users/maurycy/Desktop/copyparty/copyparty/httpcli.py:335\n 6245 \u003cmodule> /Users/maurycy/Desktop/copyparty/copyparty/util.py:1\n 5087 Up2k._handle_json /Users/maurycy/Desktop/copyparty/copyparty/up2k.py:3035\n 4146 SvcHub.__init__ /Users/maurycy/Desktop/copyparty/copyparty/svchub.py:136\n 4133 HttpCli.handle_plain_upload /Users/maurycy/Desktop/copyparty/copyparty/httpcli.py:3648\n 3753 HttpCli.dump_to_file /Users/maurycy/Desktop/copyparty/copyparty/httpcli.py:2444\n```\n\nThe 4096 limit is too small even for our stdlib:\n\n```bash\n2026-06-06T17:14:47.179006000+0200 maurycy@gimel /Users/maurycy/work/cpython (main fded34d*?) % uv run linetable_dist.py ~/work/cpython/Lib \nobjects=92035 median=49 max=37416 >4096=37\n 37416 \u003cmodule> /Users/maurycy/work/cpython/Lib/html/entities.py:1\n 20958 \u003cmodule> /Users/maurycy/work/cpython/Lib/test/test_ast/snippets.py:1\n 17060 \u003cmodule> /Users/maurycy/work/cpython/Lib/locale.py:1\n 11158 \u003cmodule> /Users/maurycy/work/cpython/Lib/test/test_dis.py:1\n 10063 SuggestionFormattingTestBase.test_name_error_suggestions_do_not_trigger_for_too_many_locals.\u003clocals>.func /Users/maurycy/work/cpython/Lib/test/test_traceback.py:4899\n 9953 \u003cmodule> /Users/maurycy/work/cpython/Lib/stringprep.py:1\n 9400 \u003cmodule> /Users/maurycy/work/cpython/Lib/test/re_tests.py:1\n 5892 \u003cmodule> /Users/maurycy/work/cpython/Lib/encodings/aliases.py:1\n 5791 \u003cmodule> /Users/maurycy/work/cpython/Lib/test/test_socket.py:1\n 5730 \u003cmodule> /Users/maurycy/work/cpython/Lib/encodings/mac_arabic.py:1\n 5730 \u003cmodule> /Users/maurycy/work/cpython/Lib/encodings/cp866.py:1\n 5730 \u003cmodule> /Users/maurycy/work/cpython/Lib/encodings/cp865.py:1\n 5730 \u003cmodule> /Users/maurycy/work/cpython/Lib/encodings/cp863.py:1\n 5730 \u003cmodule> /Users/maurycy/work/cpython/Lib/encodings/cp862.py:1\n 5730 \u003cmodule> /Users/maurycy/work/cpython/Lib/encodings/cp861.py:1\n```\n\n# Reproduction\n\nUsing real file from stdlib:\n\n```python\nimport os, _remote_debugging\n\nsrc = open(\"/Users/maurycy/work/cpython/Lib/html/entities.py\").read()\nsrc += \"\\n_remote_debugging.RemoteUnwinder(os.getpid()).get_stack_trace()\\n\"\nexec(compile(src, \"entities.py\", \"exec\"))\nprint(\"OK\")\n```\n\nWe get:\n\n```bash\n2026-06-06T17:17:34.919627000+0200 maurycy@gimel /Users/maurycy/work/cpython (main fded34d*?) % uv run repro.py\nTraceback (most recent call last):\n File \"/Users/maurycy/src/github.com/maurycy/cpython/repro.py\", line 5, in \u003cmodule>\n exec(compile(src, \"entities.py\", \"exec\"))\n ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"entities.py\", line 2515, in \u003cmodule>\nRuntimeError: Invalid bytes length (37445) at 0xc5091c000\n```\n\n# Bonus\n\n(thx Claude)\n\n\u003cdetails>\n\u003csummary>\u003ccode>linetable_dist.py\u003c/code>\u003c/summary>\n\n```python\n#!/usr/bin/env python3\nimport warnings\nfrom pathlib import Path\nfrom statistics import median\nfrom sys import argv\nfrom types import CodeType\n\nwarnings.simplefilter(\"ignore\")\nSKIP = {\"venv\", \"site-packages\", \"__pycache__\"}\n\n\ndef codes(co):\n yield co\n for c in co.co_consts:\n if isinstance(c, CodeType):\n yield from codes(c)\n\n\nrows = []\nfor arg in argv[1:]:\n p = Path(arg).expanduser()\n for f in [p] if p.is_file() else p.rglob(\"*.py\"):\n if SKIP & set(f.parts):\n continue\n try:\n co = compile(f.read_text(errors=\"replace\"), str(f), \"exec\")\n except Exception:\n continue\n rows += [(len(c.co_linetable), str(f), c.co_qualname, c.co_firstlineno)\n for c in codes(co)]\n\nrows.sort(reverse=True)\nvals = [s for s, *_ in rows]\n\nprint(f\"objects={len(vals)} median={median(vals):.0f} max={max(vals)} \"\n f\">4096={sum(v > 4096 for v in vals)}\")\nfor s, fn, qual, lineno in rows[:15]:\n print(f\"{s:8d} {qual:24s} {fn}:{lineno}\")\n```\n\n\u003c/details>\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-151036\n* gh-154187\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maurycy","@type":"Person","name":"maurycy"},"datePublished":"2026-06-06T15:22:16Z","url":"https://github.com/python/cpython/issues/151022"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6420d6bb-148d-201a-e3e5-dd837b67459d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D346:21DFED:CF45C7:1060A0F:6B022F69 |
| html-safe-nonce | 8bc4f35fad311833e304cb81df15e388234b486458d2318c1748ac84900960c0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzQ2OjIxREZFRDpDRjQ1Qzc6MTA2MEEwRjo2QjAyMkY2OSIsInZpc2l0b3JfaWQiOiIxMjYxNzI5NzYxMjAyNDE3NTEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6e7ef2b989c8288382973a30cc36ca63be874e4422bd26f4bd9778e3b1ec6548 |
| hovercard-subject-tag | issue:4604033721 |
| 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/151022/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa209de8f7832ce516b70de377d948e0c3337d13b3d48c6eb68e8aec9458eed5/python/cpython/issues/151022 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa209de8f7832ce516b70de377d948e0c3337d13b3d48c6eb68e8aec9458eed5/python/cpython/issues/151022 |
| og:image:alt | Bug report Bug description: I've reproduced the issue reported in https://discuss.python.org/t/tachyon-97-error-rate/107619 The issue is caused by: cpython/Modules/_remote_debugging/code_objects.c ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maurycy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width