loader: write the guest fault context into the log file #2227
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!2227
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2227"
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?
@Nawid3333 on GitHub · 2026-11-12 05:34 UTC · original
Nawid3333:fix/fault-report-in-log→main· +172 −32 · 3 files · 5 commits · openCause
With file logging (
_kyty.txt),Log::Writegoes to a spdlog file sink andstd::printfreaches only the console (Log::Initialize, src/common/logging/log.cpp). The host exception handler prints the guest fault context (thread, registers, the code bytes around pc, the top of the stack) withstd::printf, then callsEXIT, which writes its error line withLog::WriteToConsoleAndLog. So the log attached to a report has theUnhandled host exceptionline but not the context. Of the 34_kyty.txtattached to issues here that containUnhandled host exception, one has the context block, and that one is a console capture saved under that name. #2206 is a recent example.Change
Loader::ReportUnhandledHostException, so a test can run it.fmt::basic_memory_bufferwithfmt::format_to, so nothing is allocated before the output) and writes it withLog::WriteToConsoleAndLog, the callEXITuses, beforeEXIT.With file logging the block now reaches the console and the file. With console logging it is printed once, as before. With silent logging it still goes to the console.
Test
FaultReportReachesTheLogFileinvirtual_memory_allocation_testsstarts the test binary again with--fault-report <file>. That child turns on file logging and callsReportUnhandledHostExceptionwith a made-up access violation whose pc and rsp point into two static arrays. The parent checks that the child ended throughEXITand that the file holds the error line, the context header with the thread andrax, the code row with the byte at pc, and the first stack row. A child that has not ended within the test's timeout is killed and the test fails. The child sets up only configuration and logging (third commit): the full test start reserves the guest memory, and on a Windows CI runner that reservation failed in the child, which then ended throughEXITbefore file logging was on.FaultReportReachesTheLogFile failed: the guest fault context is missing from the log fileVirtualMemoryAllocationTests: all cases passed(Local build: Windows 11, clang-cl.)
Fork CI (run):
virtual_memory_allocationpassed on Windows, Linux and macOS.Written with Claude Code (AI): Claude Code wrote the change and the test and ran them; Claude Opus reviewed the diff.
@coderabbitai[bot] on GitHub · 2026-11-12 05:37 UTC · original · edited 2026-11-23 23:47 UTC
No actionable comments were generated in the recent review.
Walkthrough
The exception handler now uses
ReportUnhandledHostExceptionto report unhandled host exceptions. The function formats guest fault context in a memory buffer and writes the report to the console and log. The test suite adds a child-process test that triggers a synthetic access violation and checks the log contents and child exit status.Suggested reviewers:
nmzik,ew-sudoChange: Bug fix
Merge Risk:
Minimal · up to
6b56eUnhandled host exception reports now reach the log file as well as the console. No merge-blocking risk was identified in the supplied change.
Pre-merge checks:
4
Full details: Title check
Explanation
The title "loader: write the guest fault context into the log file" matches the main change. The PR moves the unhandled host exception report into Loader::ReportUnhandledHostException and writes it through Log::WriteToConsoleAndLog, so the context reaches the file log. The title is specific and concise, and it follows the repository's scope-prefixed style.
Full details: Description check
Explanation
The description explains the cause (std::printf reaching only the console under file logging), the change (a new ReportUnhandledHostException function, a stack-buffer report sent through Log::WriteToConsoleAndLog before EXIT), and the test (FaultReportReachesTheLogFile with a child process). All of this matches the raw summary and the objectives.
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
dcd69bf4-73cb-43c5-966e-846c4cd45e57Reviewing files that changed from the base of the PR and between
22f880fc65and6b56e45e38.tests/VirtualMemoryAllocationTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.