Repository navigation
Tachyon sample dump/replay crashes #144336
Copy link
Copy link
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-profilingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug description:
I'm running python -m profiling.sampling replay prof.bin --heatmap after having captured some profile and it crashes.
When I dropped a breakpoint in I saw the dump somehow has ended up with one instance where stat.filename == '\x00'
Error: Failed to export heatmap: embedded null byte
Traceback (most recent call last):
File "<frozen runpy>", line 196, in _run_module_as_main
File "<frozen runpy>", line 87, in _run_code
File "/.../lib/python3.15/profiling/sampling/__main__.py", line 65, in <module>
main()
~~~~^^
File "/.../lib/python3.15/profiling/sampling/cli.py", line 788, in main
_main()
~~~~~^^
File "/.../lib/python3.15/profiling/sampling/cli.py", line 922, in _main
handler(args)
~~~~~~~^^^^^^
File "/.../lib/python3.15/profiling/sampling/cli.py", line 1206, in _handle_replay
collector.export(filename)
~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/.../lib/python3.15/profiling/sampling/heatmap_collector.py", line 725, in export
self._generate_file_reports(output_dir, file_stats)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../lib/python3.15/profiling/sampling/heatmap_collector.py", line 766, in _generate_file_reports
self._generate_file_html(
~~~~~~~~~~~~~~~~~~~~~~~~^
file_path,
^^^^^^^^^^
...<3 lines>...
stat
^^^^
)
^
File "/.../lib/python3.15/profiling/sampling/heatmap_collector.py", line 905, in _generate_file_html
source_lines = Path(filename).read_text(encoding='utf-8', errors='replace').splitlines()
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../lib/python3.15/pathlib/__init__.py", line 985, in read_text
with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../lib/python3.15/pathlib/__init__.py", line 969, in open
return io.open(self, mode, buffering, encoding, errors, newline)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: embedded null byteDon't yet have a minimal repro, but maybe the issue is apparent to you
CPython versions tested on:
3.15
Operating systems tested on:
macOS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-profilingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
[-]Tachyon sample dump/replay has issue with bad filename[/-][+]Tachyon sample dump/replay crashes[/+]StanFromIreland commentedon Jan 30, 2026
Maybe after reading the filename in
parse_code_object, we should check the content and not just the length? WDYT @pablogsalpablogsal commentedon Jan 30, 2026
Unfortunately not :(
If you could have a repro or you can send over the file that would be amazing!
pablogsal commentedon Jan 30, 2026
Oh wait this is opening a python file:
It's here:
cpython/Lib/profiling/sampling/heatmap_collector.py
Line 905 in 96e4cd6
Is not the result file is just a python file!
pablogsal commentedon Jan 30, 2026
Ah damn, ok, the filename comes from
stat.filename. Yeah I think i still would like to see at least the filehauntsaninja commentedon Feb 2, 2026
Let me try to figure out a repro or shareable dump.
In the meantime, here's something maybe useful from the bad file I have:
There is a second instance as well. That one is:
pablogsal commentedon Feb 3, 2026
@hauntsaninja can you try to apply this diff and see if it reproduces?
ivonastojanovic commentedon Oct 23, 2026
Closing this one since this was fixed in #158853.