loader: report the module and cause behind a guest fault #563

Closed
github-bot wants to merge 1 commit from gh-pr/563/head into gh-pr/563/base
Owner

@⁠psnwd on GitHub · 2026-09-11 16:45 UTC · original
psnwd:fix/runtime-linker-fault-diagnostics → main · +107 −28 · 3 files · 1 commits · closed without merging

The fatal line for an unhandled host exception printed raw enum ordinals and a bare address, so reports arrived unusable: "access=1" means AccessViolationType::Read, not a write, and a guest pc means nothing without the module it belongs to. The guest fault context collected just above it -- thread, registers, faulting code bytes, stack top -- went to std::printf only, so it never reached the log file people attach to bug reports and was lost entirely for launcher-started runs.

Route that block through Log::WriteFatal, the path the fatal error already takes, leaving console output as it was. Resolve both the faulting pc and the faulted address to module+offset, print the exception and access types by name with the native code in hex, and call out an all-ones address as a -1 sentinel used as a pointer.

Resolving an address from the handler needs a lookup that cannot block: add RuntimeLinker::TryFindProgramByAddr, which gives up rather than wait if the thread faulted while holding the linker lock. The shared segment scan no longer asserts on a half-built program, since aborting inside a fault handler would destroy the diagnostic being collected.

Also name the unwind boundary constant in KernelGetModuleInfoForUnwind and record where it sits in the guest address space. Its value is unchanged: it has never been tied to a specific host allocation, so narrowing it without a reproduction would risk titles that currently unwind correctly.

issue: #495

**@⁠psnwd** on GitHub · 2026-09-11 16:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/563) `psnwd:fix/runtime-linker-fault-diagnostics` → `main` · +107 −28 · 3 files · 1 commits · closed without merging The fatal line for an unhandled host exception printed raw enum ordinals and a bare address, so reports arrived unusable: "access=1" means AccessViolationType::Read, not a write, and a guest pc means nothing without the module it belongs to. The guest fault context collected just above it -- thread, registers, faulting code bytes, stack top -- went to std::printf only, so it never reached the log file people attach to bug reports and was lost entirely for launcher-started runs. Route that block through Log::WriteFatal, the path the fatal error already takes, leaving console output as it was. Resolve both the faulting pc and the faulted address to module+offset, print the exception and access types by name with the native code in hex, and call out an all-ones address as a -1 sentinel used as a pointer. Resolving an address from the handler needs a lookup that cannot block: add RuntimeLinker::TryFindProgramByAddr, which gives up rather than wait if the thread faulted while holding the linker lock. The shared segment scan no longer asserts on a half-built program, since aborting inside a fault handler would destroy the diagnostic being collected. Also name the unwind boundary constant in KernelGetModuleInfoForUnwind and record where it sits in the guest address space. Its value is unchanged: it has never been tied to a specific host allocation, so narrowing it without a reproduction would risk titles that currently unwind correctly. issue: #495
The fatal line for an unhandled host exception printed raw enum ordinals and
a bare address, so reports arrived unusable: "access=1" means
AccessViolationType::Read, not a write, and a guest pc means nothing without
the module it belongs to. The guest fault context collected just above it --
thread, registers, faulting code bytes, stack top -- went to std::printf
only, so it never reached the log file people attach to bug reports and was
lost entirely for launcher-started runs.

Route that block through Log::WriteFatal, the path the fatal error already
takes, leaving console output as it was. Resolve both the faulting pc and the
faulted address to module+offset, print the exception and access types by
name with the native code in hex, and call out an all-ones address as a -1
sentinel used as a pointer.

Resolving an address from the handler needs a lookup that cannot block: add
RuntimeLinker::TryFindProgramByAddr, which gives up rather than wait if the
thread faulted while holding the linker lock. The shared segment scan no
longer asserts on a half-built program, since aborting inside a fault handler
would destroy the diagnostic being collected.

Also name the unwind boundary constant in KernelGetModuleInfoForUnwind and
record where it sits in the guest address space. Its value is unchanged: it
has never been tied to a specific host allocation, so narrowing it without a
reproduction would risk titles that currently unwind correctly.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:25:50 +00:00
github-bot closed this pull request 2026-11-26 09:25:50 +00:00
Author
Owner

@⁠Nmzik on GitHub · 2026-10-03 13:43 UTC · original

This is debugging/dev. Lets not overcomplicate :)

**@⁠Nmzik** on GitHub · 2026-10-03 13:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/563#issuecomment-5969740093) This is debugging/dev. Lets not overcomplicate :)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.