On 32-bit builds the new profiler binary reader can mis-handle large stack-depth values while decoding certain .pyb inputs because currently computes the final depth with size_t arithmetic; if that arithmetic wraps, the later bounds check is performed on the wrong value and decoding can fail incorrectly.
Activity
pythongh-148252: Fix stack depth calculation in binary reader on 32-b…
pablogsal commented on Apr 8, 2026
Issue originally found and identified thanks to the great work of @TristanInSec. Thanks a lot ❤️
pythongh-148252: Fix stack depth calculation in binary reader on 32-b…
pythongh-148252: Fix stack depth calculation in binary reader on 32-b…
gh-148252: Fix stack depth calculation in binary reader on 32-bit pla…
maurycy commented on Apr 24, 2026
@pablogsal
Do you think these are worthy fixing, too?
2026-04-23T23:21:18.263590000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython/Modules/_remote_debugging (main 448d7b9) % rg -n 'if .*\+.*>.*(size|len|capacity|limit|max)' --glob '*.[ch]' binary_io_reader.c 261: if (offset + str_len > file_size) { 980: if (offset + 13 > reader->sample_data_size) {This is a pretty similar pattern.
I can handle this.
pablogsal commented on Apr 24, 2026
Yeah happy to take a PR if you want to make one
pythongh-148252: Fix stack depth calculation in binary reader on 32-b…
gh-148252: Avoid overflow in `_remote_debugging` binary reader bounds…