(found while thinking about how to address the code review from #157228)
The timestamp is advanced before the stack is built:
https://github.com/python/cpython/blob/b9546455ab0/Modules/_remote_debugging/binary_io_writer.c#L952-L953
If there's a failure, such as:
cpython/Lib/profiling/sampling/sample.py
Lines 180 to 184 in 763b6ed
Then the timestamps for the thread is shifted. That's a hard corruption for a delta-based format.
maurycy@gimel cpython-315 (main e580c88?) % cat repro.py import _remote_debugging w = _remote_debugging.BinaryWriter("/tmp/o.bin", 1000, 0) try: w.write_sample([(0, [(1, 0, [(42, None, "f", None)])])], 5000) except TypeError: pass w.write_sample([(0, [(1, 0, [("a.py", None, "f", None)])])], 6000) w.finalize() class C: def collect(self, frames, timestamps_us=None, **kw): print(timestamps_us) _remote_debugging.BinaryReader("/tmp/o.bin").replay(C()) maurycy@gimel cpython-315 (main e580c88?) % ./python.exe repro.py [1000]
Another repro could involve _testcapi.set_nomemory, incorrect unicode etc.
CPython main branch, 3.15
macOS
Duplicated by #152892 and #158830
Activity
maurycy commented on Oct 5, 2026
Duplicated by #152892 and #158830