fix(libc): report integer overflow faults in the Windows crash report #14405
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14405"
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-11-01T11:35:32Z.
What
On
26fa1212b8(line numbers below refer to it) a guestidivofINT_MINby-1on Windows ends the process without a crash report. Guest code runs natively, and on x64DIV/IDIVraise the same divide error (#DE) for a zero divisor and for a quotient that does not fit the destination (Intel SDM, DIV and IDIV); Windows reports the first asEXCEPTION_INT_DIVIDE_BY_ZERO(0xC0000094) and the second asEXCEPTION_INT_OVERFLOW(0xC0000095), and sinceINTOis invalid in 64-bit mode, 0xC0000095 has no other hardware source. The vectored handlerReportCrash(installed atcore/libs/prx/libc/src/specifics/windows/CrashReport.cpp:677) reports only codes thatIsFatallists (CrashReport.cpp:72-85), and that list has 0xC0000094 (line 78) but not 0xC0000095, so the overflow returnsEXCEPTION_CONTINUE_SEARCHat line 365 and prints noFATALline, no registers, no call trace and nothing to theANYPS5_LOG_FILEcopy. The repository already treats both codes as one class:ChildProcessWaitStatusmaps both toSIGFPE(core/libs/prx/libc/src/Process.cpp:304-305), and open #14298 reportsSIGFPEas fatal on Linux, which covers both outcomes there.IsFatallistsEXCEPTION_INT_OVERFLOWnext toEXCEPTION_INT_DIVIDE_BY_ZERO, so both outcomes of the divide error are reported the same way. Nothing else changes:ReportCrashstill returnsEXCEPTION_CONTINUE_SEARCHafter the report (line 477), so whether and how the process ends is unchanged. Vectored handlers added withFirst=1after libc loads still run beforeReportCrash, and open #7192 calls itsHandleHostFaultinsideReportCrashbefore theIsFatalcheck, so a guest handler keeps the first chance. Floating-point codes, misalignment, breakpoints and single steps stay unlisted.windows_integer_overflow_report(Windows only) loads libc, then dividesINT_MINby-1withcltd; idivlfrom registers the compiler cannot fold, and expectsdividingfollowed byFATAL: unhandled exception 0xc0000095;did not faultfails it. No existing test raises 0xC0000095 or dividesINT_MINby-1.pr_overlap.py --branchfinds no shared lines with the open pull requests it can compare and cannot compare 17 that do not merge withmain: #7192, #11628, #11661, #11689 and #11698 sharewindows/CrashReport.cpp, and #5021, #7275, #8650, #9156, #9162, #9293, #9297, #9302, #9383, #12642, #13253 and #13256 sharecore/libs/CMakeLists.txt. Checked by hand: a trial merge of this branch with each of them conflicts in exactly the files thatmainwith it already conflicts in, so this change adds no conflict.Tested
Windows 11, WinLibs GCC 15.2.0, Ninja Release build (
BUILD_TESTING=ON) of the targetslibc,windows_integer_overflow_report_testsandwindows_crash_text_testson25ee90defa(based on26fa1212b8; it merges cleanly withmainate67cc81869, which changes none of the three touched files):cmake --build build --target windows_integer_overflow_report_tests windows_crash_text_tests libc, thenctest --test-dir build -R "^(windows_integer_overflow_report|windows_crash_text)$" -V.IsFatalof26fa1212b8:windows_integer_overflow_reportfails withRequired regular expression not found; its whole output isdividing, and run directly the test exits with 3 from its unhandled-exception filter, so the fault happened but nothing was reported.windows_crash_textpasses.dividing,FATAL: unhandled exception 0xc0000095,rip ... windows_integer_overflow_report_tests.exe+0x91b9(theidiv %r10d, withr10=0xffffffffandrax=0x80000000in the register dump) and the rest of the report;windows_crash_textstill reports its access violation as before.configure_host_test_executable(docs/dev/CONVENTIONS.md, host-only test executables), so it links with-static -static-libgcc -static-libstdc++andobjdump -pshows nolibstdc++-6.dllimport; with that,ctest --test-dir build -R '^(windows_integer_overflow_report|windows_crash_text)$'passes 2/2.python tools/check_conventions.py --base 26fa1212b8with this title and description passed.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-11-01T12:47:51Z.
Review: COMMENTED
Reviewed — no blocking findings
The one-line change classifies
EXCEPTION_INT_OVERFLOWas a fatal fault inIsFatal, next to the existing integer-divide case, and the hosted Windows run for this head passed all 2585 CTest tests, includingwindows_integer_overflow_report_tests; I found no blocking issue at25ee90defa.What I ran
Exact head
25ee90defae602a4526baf0cc1a119debe6252b7; PR baseb2620e56d114ef053f8b45433b1d48aff7ec37ba(precheck base), unchanged at completion. No local build and no local test run. Commands:The precheck's ABI and test-quality helpers were missing from the isolated head tree, so both were run by hand. I also read the changed hunk (
core/libs/prx/libc/src/specifics/windows/CrashReport.cppL75-L82) andProcess.cppL305, which maps0xC0000095to SIGFPE (8).Results
possible-unregistered-cpp-testfinding; false positive, because the test is registered incore/libs/CMakeLists.txtL683-L685windows_integer_overflow_report_testsFindings
Blocking: none.
Non-blocking: none.
Not verified
To get this to a good state
No change is needed for this review.