common: report the exception record of a fault the vectored handler d… #1409
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1409
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1409/head"
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?
@Franseven on GitHub · 2026-10-11 08:41 UTC · original
Franseven:pr/unhandled-fault→main· +25 −0 · 1 files · 1 commits · closed without mergingProblem
ExceptionFilter, the vectored exception handler installed byCommon::HostException::InstallHandler, classifies exactly two codes:EXCEPTION_CONTINUE_SEARCHwith noSetUnhandledExceptionFilterinstalled means the process is terminated by the OS with an exit code and no output at all. Nothing in the log says what faulted, in which module, or at which address.Several faults that end runs land here:
0xC00000FDSTATUS_STACK_OVERFLOW— a shader whose control flow recurses deeply enough in the structurizer to exhaust the host stack;0xC0000094EXCEPTION_INT_DIVIDE_BY_ZERO;0xC0000409STATUS_STACK_BUFFER_OVERRUN, which is what__fastfailand the MSVC security cookie raise;The handler is also declined when it returns
false, i.e. when the guest fault could not be attributed to a known GPU access, so the same silent exit covers that case too.Change
Install a last-resort filter behind the vectored handler:
Three deliberate limits:
SetUnhandledExceptionFilterruns only after the vectored handler has had its turn and declined, so the existing access-violation and illegal-instruction reports are unchanged.EXCEPTION_CONTINUE_SEARCHis returned, so the default handling — the exit code, WER, an attached debugger — is unchanged as well.Testing
Built with clang-cl 23.1.3 (Release) on Windows; the emulator links and runs, and the existing report path is untouched because the filter only runs after the vectored handler declines.
@coderabbitai[bot] on GitHub · 2026-10-11 08:45 UTC · original
📝 Walkthrough
Walkthrough
On Windows,
InstallHandlernow registers an unhandled-exception filter before the vectored exception handler. The filter prints the exception code and instruction address, and prints the fault address when available. It flushes stdout when an exception record is available and returnsEXCEPTION_CONTINUE_SEARCH.Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Feature
Merge Risk: 🔵 Low · up to
9d97bSome crash reports may show an unrelated value as the fault address, making diagnosis harder. Correct the reporting before merging; the issue does not change how exceptions are handled.
Pre-merge checks |
4 |
1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -282,0 +295,4 @@"code=0x%08" PRIx32 " pc=0x%016" PRIx64 " fault=0x%016" PRIx64 "\n",static_cast<uint32_t>(record->ExceptionCode),reinterpret_cast<uint64_t>(record->ExceptionAddress),record->NumberParameters > 1 ? record->ExceptionInformation[1] : 0);@coderabbitai[bot] on GitHub · 2026-10-11 08:45 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Only report a fault address for exception codes that define one.
Line 298 treats any second exception parameter as a fault address. Windows defines that parameter as an inaccessible address for access violations and in-page errors; for most other exception codes, the parameters are undefined. A software exception with two parameters can therefore print unrelated data as
fault. Print the address only for exception codes with a defined fault-address parameter, and mark it unavailable otherwise. (learn.microsoft.com)@coderabbitai[bot] on GitHub · 2026-10-11 08:45 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
ee10818b-d584-4cb5-9c8d-9498095baec5📥 Commits
Reviewing files that changed from the base of the PR and between
6f0cddd440and9d97bbc107.📒 Files selected for processing (1)
src/common/hostException.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
@theantipopau on GitHub · 2026-10-12 11:13 UTC · original
Small and correct.
ExceptionFilter(the VEH) only accepts AV and illegal-instruction faults and continues for everything else (hostException.cpp), so today a stack overflow / divide / fail-fast inside or outside the handler dies with an exit code and no description at all.SetUnhandledExceptionFilterwithEXCEPTION_CONTINUE_SEARCHis the standard last-resort layer for exactly this, it cannot shadow the VEH since VEH runs first, and being installed insideInstallHandlermeans it's also torn down with the same lifetime. Only printing the record (no guest-state reads) is the right safety envelope for a filter that runs after something went deeply wrong. printf+fflush is async-signal-safe enough for a process that is dead anyway.@Nawid3333 on GitHub · 2026-11-12 04:08 UTC · original
With file logging (the
_kyty.txtthat reports attach),std::printfoutput does not reach the file:Log::InitializesendsLog::Writeto a spdlog file sink and leaves stdout on the console (src/common/logging/log.cpp atbc934ef03). Main's own guest fault context is printed withstd::printftoo (src/loader/runtimeLinker.cpp:689-714) and shows it: of the 34_kyty.txtattached to issues that contain "Unhandled host exception", one has the "Guest fault context" block, and that one is a console capture saved under that name (it also holds theInitialized: ...lines, which go to stdout only). Of the 17 such logs attached under other names, 16 have the block.So as written, the
--- Unhandled host fault ---line this PR prints (std::printf, thenstd::fflush(stdout), thenEXCEPTION_CONTINUE_SEARCH) would appear in the console window but not in_kyty.txt.Log::WriteToConsoleAndLog, which EXIT uses (src/common/assert.cpp:14), writes to both and then flushes the file sink. Without that flush, the sink's buffered last lines are also missing from the file when the process ends this way.Recent reports where the reporter describes a crash and the attached log ends with no error line: #2045 (Hellblade), #2198 (Stray), #2220 (Viewfinder), #2211 (Saros).
Pull request closed