Skip to content

Crash reports: show the bytes of an instruction the CPU refused - #198

Merged
Marvisak merged 1 commit into
Marvisak:mainfrom
Dufftwt:fix/crash-report-instruction-bytes
Nov 24, 2026
Merged

Marvisak merged 1 commit into
Marvisak:mainfrom
Dufftwt:fix/crash-report-instruction-bytes

Conversation

@Dufftwt

@Dufftwt Dufftwt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What's wrong

When the CPU refuses an instruction (0xc000001d illegal instruction, 0xc0000096 privileged instruction), the crash report gives only its address:

VIctory: unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f.dll+0x4ecc84a

The address doesn't say which instruction failed. On Intel hosts that is the first question every one of these reports raises, because the console's Zen 2 CPU has instructions Intel CPUs lack: clwb, clzero, monitorx/mwaitx, rdpru, SSE4a. The loader emulates the ones it knows, and the next one it doesn't know shows up as exactly this line. So far reporters have had to guess (#103 suggests "SHA-NI, SSE4a, or RDPID" for what turned out to be clwb) or dump the bytes by hand (#7). The reply in #106 asks for the address and the CPU model "to tell which encoding" it was, and #85's local patch logged the bytes for the same reason.

What the fix does

For these two exceptions, report in crash.rs now adds the bytes at the faulting address to the end of the report's first line:

  • It shows up to 15 bytes (the longest x86 instruction) as hex.
  • It never reads past the end of the faulting address's page, because the next page may not be mapped. The emulation in emulate_amd_only already reads instruction bytes under the same rule.

Other exceptions, the register lines and the stack lines don't change.

How it behaves after the fix

The report names the instruction by itself, in the console output and in crashes.log alike:

VIctory: unhandled exception 0xc000001d at victory-image-….dll+0x4ecc84a (code 66 0f ae 30 …)

0f 01 fd is rdpru, 66 0f ae /6 is clwb, and so on, so whoever reads the report can tell which instruction is missing without a debugger or the title's files.

Tests

The new test instruction_bytes_stop_at_the_end_of_their_page covers the byte reader:

  • From the start of a page, it gives 15 bytes.
  • For an instruction in the last 3 bytes of a page whose next page is PAGE_NOACCESS, it gives exactly those 3 bytes and doesn't fault.

I ran cargo test --workspace on GitHub's windows-latest with Rust 1.98.1 from rust-toolchain.toml:

  • This PR: everything passes. victory-loader has 19 passed, the other crates have 0 failed.
  • The report line itself: a throwaway test, used only on my CI branch, hands report an illegal instruction at the bytes of rdpru. On main it prints
    VIctory: unhandled exception 0xc000001d at victory_loader-….exe+0xf9cf0
    
    and with this PR
    VIctory: unhandled exception 0xc000001d at victory_loader-….exe+0xfd3e0 (code 0f 01 fd 48 89 c1 90 90 90 90 90 90 90 90 90)
    
  • I ran with --test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (STATUS_ACCESS_VIOLATION), on unmodified main as well.

Not tested: a real illegal instruction on an Intel host, or the title.

Related: #7, #85, #102, #103, #106 (Intel hosts, 0xc000001d). #34 adds rdpru and clzero loops; this change doesn't overlap it.

An illegal or privileged instruction is reported by its address only,
which does not say which instruction it was. On an Intel host that is
the question every such report raises (clwb, clzero, rdpru, an SSE4a
form...), and reporters have had to guess or dump the bytes by hand.

The report's first line now ends with up to 15 bytes at the faulting
address, as hex, read no further than the end of that page, so the
report names the instruction by itself.
@DaviTostes

Copy link
Copy Markdown

Tested babe2db under Wine 11.22 + vkd3d-proton 3.1 (Arch Linux x86_64, AMD RX 9060 XT, RADV 26.3.1), Windows build of the loader:

  • victory_loader (lib): 19 passed, 0 failed — one more than before, the new instruction-bytes test.
  • tests/crash_log.rs: 1 passed (first_chance_breakpoint_logging).
  • The Linux build of the loader cannot run these tests (they parse the test binary as PE, and it is ELF); the Windows build under Wine is the right check here.

No game data used.

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…U refused

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Marvisak
Marvisak merged commit 3dd37e6 into Marvisak:main Nov 24, 2026
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
Crash reports: show the bytes of an instruction the CPU refused
itsonlysimbo pushed a commit to itsonlysimbo/VIctory that referenced this pull request Nov 24, 2026
…tion-bytes

Crash reports: show the bytes of an instruction the CPU refused
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants