Merged upstreamCorrectnessMerged Jul 19, 2026
Fix remote debugging linetable reads
Fixed CPython's _remote_debugging stack trace path for valid code objects whose line tables exceed the previous 4096-byte read limit.
python/cpython · #151036
Problem
RemoteUnwinder read a code object's line table from the target process with a fixed 4096-byte cap. Valid stdlib and third-party code objects can exceed that size, so get_stack_trace could fail with RuntimeError: Invalid bytes length instead of returning the stack.
Approach
Gave code-object line table reads a dedicated 64 KiB bound while keeping the generic remote byte reader bounded. Added a same-process regression that builds a code object with a line table larger than 4096 bytes and verifies stack trace line resolution still succeeds.
Impact and scope
- Restores CPython external inspection for valid large-linetable code objects in stdlib-scale and real-world applications.
- Keeps remote memory reads bounded instead of removing safety limits from the shared byte-reading helper.
- Improves reliability of Python debugging and profiling surfaces that depend on _remote_debugging stack traces.
Validation
- Added TestSelfStackTrace.test_self_trace_with_large_linetable for a generated code object above the old 4096-byte boundary.
- PR evidence includes focused unittest coverage, the full test_external_inspection suite, and make patchcheck.
- Core maintainer review accepted the 64 KiB bound as reasonable for the stdlib and reported third-party linetable sizes.