Skip to content

Crash reports: say what an access violation's address holds - #204

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

Marvisak merged 1 commit into
Marvisak:mainfrom
Dufftwt:fix/crash-report-fault-memory

Conversation

@Dufftwt

@Dufftwt Dufftwt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What's wrong

An access violation is reported with the kind of access and the address it touched, and nothing else:

VIctory: unhandled exception 0xc0000005 at victory-image-….dll+0x4e33a92 (write 0x325a0570)

The address alone can't tell apart causes that need completely different fixes:

Today, finding out which one it was means asking the reporter for a dump and a debugger session. #99 is an example: three runs show "a write below 4 GB" with nothing more to go on.

What the fix does

report in crash.rs now asks VirtualQuery what is at the faulting address, and adds the answer after the address. A new helper, memory_at, turns the answer into one of these:

  • nothing mapped there
  • reserved, never committed
  • a guard page
  • the page's protection (read-only, read-write, read-execute, no access, …), and the module name with offset when the page belongs to a loaded image
  • outside the address space, for addresses VirtualQuery rejects, such as the all-ones address Windows reports for a non-canonical pointer

It only queries the address space; it never reads the faulting address itself, so it can't fault inside the handler. Other exceptions and the rest of the report don't change.

How it behaves after the fix

VIctory: unhandled exception 0xc0000005 at victory-image-….dll+0x4e33a92 (write 0x325a0570: reserved, never committed)

A report now says by itself whether a crash is a bad pointer, an allocation that never got its memory, a stack overrun, or a write to protected memory.

Tests

The new test memory_at_names_what_an_access_hit reserves four pages and commits three of them as read-only, guard and no-access. It checks each description, then checks free memory (after releasing the pages, and address 0), an address past the end of the address space, and the test's own code (read-execute, in victory_loader-….exe+0x…).

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 lines themselves: a throwaway test, used only on my CI branch, hands report four writes: into reserved pages, a guard page, address 0x18, and the all-ones address. On main:
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x24440 (write 0x1d19a260570)
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x24440 (write 0x1d19a261010)
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x24440 (write 0x18)
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x24440 (write 0xffffffffffffffff)
    
    With this PR:
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x109a0 (write 0x12cb24d0570: reserved, never committed)
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x109a0 (write 0x12cb24d1010: a guard page)
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x109a0 (write 0x18: nothing mapped there)
    VIctory: unhandled exception 0xc0000005 at victory_loader-….exe+0x109a0 (write 0xffffffffffffffff: outside the address space)
    
  • 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 crash in the title.

Related: #23, #99. #12 and #34 also edit crash.rs; both already conflict with main, and this change adds no conflict of its own with either. It merges cleanly with #198, which adds the bytes of an illegal instruction to the same report line.

An access violation is reported with the address it touched and
nothing else, so a read of free memory, a write to memory that was
reserved but whose commit failed, a stack guard page and a write to
code or constants all look the same in a report.

The report now adds what VirtualQuery says is at that address: nothing,
reserved but never committed, a guard page, or the page's protection,
with the module for an image's pages.
muhammed-aksoy pushed a commit to muhammed-aksoy/VIctory that referenced this pull request Nov 24, 2026
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…holds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremygold02

Copy link
Copy Markdown
Contributor

Thanks @Dufftwt for the access-violation report detail. I tested the open PR at head 3390e47328e057badbb3cf2a2f565a3a05291960 with:

cargo test --locked -p victory-loader --lib memory_at_names_what_an_access_hit -- --test-threads=1

Result: 1 passed, 0 failed. The test exercises VirtualQuery classification for reserved-but-uncommitted, read-only, guard, no-access, released/free, null, and out-of-address-space locations, then checks module naming for an image page. These are synthetic memory-region checks; they do not exercise crash handling in a real title. The test is in crash.rs.

@Marvisak
Marvisak merged commit 27c960b into Marvisak:main Nov 24, 2026
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
Crash reports: say what an access violation's address holds
itsonlysimbo pushed a commit to itsonlysimbo/VIctory that referenced this pull request Nov 24, 2026
…emory

Crash reports: say what an access violation's address holds
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