feat(libc): print the text that registers point at in Windows crash reports #5962
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5962"
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 nikowolf123 on 2026-10-14T17:13:57Z.
What
Several Unreal titles on Windows end in their own libc fatal path with the
LowLevelFatalErrormessage in a register, as UTF-16. For each register, the crash report prints the eight 64-bit words it points at (CrashReport.cpp:341), so it shows only the first 64 bytes of that message, which is 32 UTF-16 characters:[r13] "LowLevelFatalError [File:Unknown] ..." (UTF-16, the dump shows 64 bytes). The reporter wrote that the text of the fatal error is not established. Other runs of it stopped on the same out-of-memory allocation as Sifu PPSA03001, whose log prints the message (#3209 comment).r12starts withLowLevelFatalError [File:Unknown]. The text is unknown because the dump keeps 64 bytes.rax deadbeefcafebabe, read of0xffffffffffffffffin the title'slibc.prx). The comment shows no message.PS5 Out of Memory. It was first found by reading the title's image (the UTF-16 format string before the fatal call), not in the report.With this change, the report prints the text at such a register up to its NUL (at most 512 characters), so the next report of a stop like the Stray one shows the message instead of its first 32 characters, as far as it is printable ASCII.
After the register memory dump, the report now checks every general register except
rsp. If a register points at readable memory that starts with at least four printable ASCII characters, it prints that text, as UTF-16LE (checked first) or as single bytes. The new Windows test's report contains, among other lines:...after the closing quote means that no NUL ended it within those limits.ReadCode(L193-L203), which checks the first page and every following page withVirtualQuerybefore reading it. Values below 0x10000 are skipped. It reads at most 1026 bytes per register.ReportCallTrace, so a stack-overflow report does not need 2 KiB more stack. The report already runs once per process.APS5_CRASH_INDIRECT_MEMORY, because a register that points at anything else adds no line.The formatting is in
core/libs/prx/libc/include/CrashText.hpp, a header without Windows calls, so its test runs on Linux too. There is no Linux crash report to extend: the whole ofCrashReport.cppis inside#ifdef _WIN32, and on Linux no host code prints the registers of a fault.docs/user/USAGE.mddescribes the new lines under "Windows crash diagnostics".#4855 (@fdfawef324) also changes
CrashReport.cpp. It adds failure-report hooks after the thread list.git merge-treemerges this branch cleanly with #4855's head82de94cbeand withmaine34c47921.Tested
Windows 11 Pro 10.0.26200 with WinLibs GCC 15.2.0 r7 (
x86_64-ucrt-posix-seh), Release, Ninja,-DBUILD_TESTING=ON. I builtlibcand the test targets below and ran them withctest --output-on-failure --timeout 120:crash_text,windows_crash_text,windows_backtrace_report,undeliverable_host_exceptionandwindows_exceptions: 5/5 pass.windows_crash_textalone: 20 of 20 repeats pass.main'sCrashReport.cppwith the rest of this branch:windows_crash_textfails withRequired regular expression not found. Its report has only the hex-word lines forr12andr13.windows_crash_textloadslibc.prxand setsr12to an ASCII string,r13to a UTF-16 string,r14to 8 text bytes that end at aPAGE_NOACCESSpage, andrbxto 8 bytes that are not text. It then reads address 8. The test passes when the report shows the three lines above and no text line forrbx. The report also prints text lines forrcx,rdxandr11, which held the same pointers.crash_textchecks the formatter in 15 cases: NUL-terminated, cut off by the end of the buffer, cut off by a non-ASCII unit, too short, a pointer value, the 512-character limit (with and without a NUL right after it), a full output buffer (also in the middle of an escape) and escaping.Linux (WSL Ubuntu, GCC 15.2.0, Release):
crash_textpasses, andtools/check_test_registration.py buildreports843 test executable(s), 0 built and not run as recorded, none new.CrashText.cppbuilt directly withg++ -O2 -fsanitize=address,undefinedalso passes.main'stools/check_conventions.py --base origin/mainpasses with this title and body.Not tested with a game: I have no PS5 dumps.
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)LowLevelFatalErrorstops on #4238)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T17:17:52Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
docs/user/USAGE.mdcore/libs/CMakeLists.txtdocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mdcore/libs/CMakeLists.txtcore/libs/CMakeLists.txtdocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mdImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T19:22:48Z.
Checked the formatter's bounds (output capacity, escape at the limit, 512-character cap, odd sizes) and the reads through
ReadCode;crash_textpasses on Linux.mainhad moved (a new include next to yours inCrashReport.cpp), so I rebased and resolved it. Merging once the Windows Build is green;windows_crash_textis the evidence for the new report lines.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T19:37:04Z.
Re-checked on the rebased head merged onto current
main: no conflicts,crash_textpasses on Linux, formatter bounds andReadCodereads unchanged from the earlier review. Merging once the Windows Build is green;windows_crash_textis the evidence for the new report lines.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T21:38:54Z.
mainadded a test block next to yours incore/libs/CMakeLists.txt; I rebased and placed thecrash_textblocks before it (no other change).crash_textpasses on Linux, formatter bounds andReadCodereads unchanged from the earlier review. Merging once the Windows Build is green;windows_crash_textis the evidence for the new report lines.