fix(tools): read sampler module names that contain spaces in symbolize_samples #13861
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13861"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-31T10:03:36Z.
What
The Windows samplers (
APS5_SAMPLE_WORKER,APS5_SAMPLE_COMMITTER,APS5_SAMPLE_THREADS) write a module's base name unquoted with%s:WorkerSampler.cpp:202writes<module> 0x<offset> <self> <inclusive>, line 288 writes the same line indented by two spaces under athreadline, and line 186 writes# module <module> 0x<size> 0x<timestamp>. On45e39c7ad1(line numbers below refer to it)tools/symbolize_samples.pysplits both kinds of line on whitespace and wants an exact field count:read_headerskeeps a record only with five fields (line 234) andloadreads an address line only with four (line 267). A module whose name contains a space, such as a Windows output namedMy Game.exe(relinker --windows eboot.elf "My Game.exe"), gives six and five fields instead. The record is dropped, so the module counts as having no# modulerecord and stays unsymbolized, and each of its address lines falls through to the collapsed-stack parser (line 272), which also ignores--thread;samples.stacksis then no longer empty, sosummarizetakes the collapsed-stack branch (line 297) and ignores every address line of the other modules. For the address file# 5 samples,My Game.exe 0x1011 3 3,ntdll.dll 0x10 2 2,# module My Game.exe 0x3000 0x6ad92ac4and a matchingMy Game.exein--libs, the tool printed3 samplesand3 100.0% My Game.exe 0x1011 3; it now prints5 samples,3 60.0% My Game.exe!shortand2 40.0% ntdll.dll+0x10.read_headerssplits a# moduleline into#,moduleand the rest, and takes the size and the timestamp from the right end of the rest, so the name keeps its spaces. Names are still compared case-insensitively.loadtakes an address line's offset and counts from the right end of the stripped line (rsplit(None, 3)), so the name keeps its spaces and the two-space indentation of thread files does not become part of it.# <n> samples,thread <id> samples <n>and collapsed-stack lines are read as before; collapsed stacks already split their count off withrpartition(" ")and their frames at+0x.# moduleline with more than five fields was ignored before. It is now a record whose name is everything betweenmoduleand the last two fields, and when either of those two is not hexadecimal it ends with the same usage error that a malformed five-field record already gave. The samplers never write such a line.pr_overlap.py --branchreports no overlap with open pull requests. #12498, #12499, #13812 and #13813 also changetools/symbolize_samples.pyand its test, in other lines; #13812 adds a check a few lines below the address-line branch ofload.Tested
Windows 11, conda Python 3.13.9, on
695da932b3(based on45e39c7ad1;mainatc3c45d73abchanged neither file and merges cleanly):python tools/tests/test_symbolize_samples.py: 38 tests, OK, 4 skipped (three need the privilege to create symbolic links on Windows, one needs an unprivileged POSIX user).test_module_names_with_spaces_keep_their_samples_and_recordscovers an address file with another module, a thread file under--thread, and a collapsed-stack file with the record; on45e39c7ad1it fails with'3 samples' != '5 samples'.python tools/check_conventions.pywith this title and description passed on695da932b3.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T10:13:50Z.
Review: APPROVED
Reviewed — looks good
The space-preserving parser change is supported by the exact-head tests and no blocking issue was found.
What I ran
Reviewed head
695da932b3f78bc5ae688b88661b65a80b0c6ce4against PR baseb7d3fd3c5218d21b626c2211c7521643efa4d572. The merge preview onto that base was clean. Environment: Linux x86_64, Python 3. The repository precheck ran these commands:Results
tools.tests.test_symbolize_samplesUnedited unit test output
Negative control
5 samples, got3 samplesUnedited negative-control failure
Not verified
I did not build or compile locally. The macOS hosted relinker jobs were still queued; the approval is based on the exact-head source review, focused Python test, negative control, and completed Linux/Windows/ASAN jobs.