feat(libc): optionally dump indirect memory in Windows crash reports #4780
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4780"
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 ivica00 on 2026-10-12T21:37:53Z.
What
Windows crash reports show the words pointed to by registers, but stop before the structures those words reference. Set
APS5_CRASH_INDIRECT_MEMORY=1to include one additional pointer level: up to eight 64-byte blocks per register, labelled with the register, pointer offset and target address. The option is disabled when unset or empty. Executable targets and reads that fail or return fewer than 64 bytes are skipped throughReadProcessMemory.This is a generic diagnostic aid.
Tested
windows_exceptionsandguest_raise_exception: passed.upstream/mainand verified withtools/check_conventions.py --base upstream/main.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 adriadam10 on 2026-10-13T15:27:08Z.
Review: CHANGES_REQUESTED
Thanks, the idea is fine and the code is small. One thing to fix:
core/libs/prx/libc/src/specifics/windows/CrashReport.cpp:285:GetEnvironmentVariableA("APS5_CRASH_INDIRECT_MEMORY", nullptr, 0) != 0returns the required buffer size including the terminator when the variable exists, so an empty value returns 1 and enables the dump. The description anddocs/user/USAGE.mdsay an empty variable keeps it disabled. Read the value into a small buffer and enable it only when it is non-empty (or exactly1, and then say so in USAGE.md, which currently documents=1while any value works).Please also check the Windows build job once pushed (PR CI skips it; it runs on dispatch). Happy to merge after that.
Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-13T17:16:50Z.
Thanks @adriadam10! Rebased onto current \upstream/main\ and updated the \APS5_CRASH_INDIRECT_MEMORY\ environment check to read into a buffer so that an unset or empty variable keeps the indirect memory dump disabled as documented in \USAGE.md.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T18:37:08Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/user/USAGE.mdL175Imported from boykopovar/AnyPS5. Originally posted by gunerky on 2026-10-13T19:11:37Z.
I checked the updated environment-value handling at PR head
139bc7b9816939bf9a00905cb12656d387cdcd2don Windows x64, WinLibs GCC 15.2.0, optimized (-O3 -DNDEBUG) with native SEH defaults. The unset/empty fix works, and the advertisedAPS5_CRASH_INDIRECT_MEMORY=1setting produces the expected indirect data.One small boundary case remains: nonempty values that do not fit in the 16-byte buffer disable the option in my run.
1,0,true, or 15xcharactersxcharactersAt the longer lengths,
GetEnvironmentVariableAreturns the required size rather than successfully filling the buffer. Microsoft documents that the buffer contents are undefined in that case, so testingindirectBuffer[0]then does not reliably implement the description's nonempty-value rule. This is a configuration edge;=1works normally.The unchanged head
CrashReport.cppandCallTrace.cppwere compiled into an isolated probe with synthetic exception data and fixture-owned memory. Correct labels/data, read-only targets, and exclusion of executable/partial/unreadable targets passed; partial, unaligned and null register roots completed without indirect output. No game was used. This probe is not a full PR build and does not replace the requested Windows build job or validate concurrent mapping changes.AI-assisted: yes; fixture, execution and result checking assisted by Codex.
Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-13T20:27:06Z.
Thanks @gunerky. The 16-byte buffer was the problem: when
GetEnvironmentVariableAcannot store the value it returns the required size and leaves the buffer undefined, soindirectBuffer[0]was not a reliable nonempty check.6d33b36e7queries the required size with a null buffer instead. An unset variable returns 0 and an empty value returns 1, so both stay disabled. Any nonempty value, including ones longer than 15 characters, returns a size greater than 1 and enables the dump.USAGE.mdis unchanged: unset or empty disables it, and any other value enables it.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T10:41:57Z.
Review: APPROVED
Checked the env-value handling (
GetEnvironmentVariableAwith a null buffer returns 0 unset, 1 empty, >1 otherwise, so> 1matches USAGE.md), the readability/executable skips and the 64-byte read, and the libc build and ctest on Linux; the Windows job covers the rest. Merging once the Windows build is green.