Skip to content

Loader: a fault while reporting one is not reported again - #3520

Open
gkissel wants to merge 2 commits into
Marvisak:mainfrom
gkissel:crash-report-reentrancy
Open

gkissel wants to merge 2 commits into
Marvisak:mainfrom
gkissel:crash-report-reentrancy

Conversation

@gkissel

@gkissel gkissel commented Nov 27, 2026 •

Copy link
Copy Markdown

AI-assisted (Claude). Measured on my own machine. What was and was not run is listed under "Tested".

Problem

Under Wine, a fault inside the crash report re-enters the vectored handler on the same thread. That report faults the same way, and the thread recurses until its stack runs out. The first report is lost and the thread dies on a stack overflow instead of the original exception.

What I saw (GTX 1650 Mobile, NVIDIA 620.70.06, Wine 11.21, vkd3d-proton 3.1, Linux): the host driver's shader compiler faulted on a pipeline worker. Wine then logged virtual_setup_exception stack overflow on two workers, at the same instruction each time. That instruction symbolizes (PDB of a local build) to victory_loader::crash::locate. Raising the worker stacks from 2 MiB to 64 MiB (RUST_MIN_STACK) moved nothing: the overflow came at the same instruction. So this is recursion, not a small stack. locate is only the deepest frame when the stack ran out. I did not pin down which call inside report faults first.

Change

report keeps a thread-local flag. If the thread is already reporting, it returns, and the nested exception goes on unreported to the next handler. This covers both callers, the vectored handler and the unhandled-exception filter. The body of report is unchanged and now lives in report_once.

Known limit, also noted in the code: if a report never returns, the flag stays set and that thread reports nothing more.

This does not overlap #1897, which recovers a faulting RtlVirtualUnwind inside the walk, or #2401, which keeps a Wine compiler crash from ending the run. Those remove two causes of a fault in or around the report. This one stops any fault in the report from recursing.

Also, module_of uses checked_sub now. Under Wine 11.21, GetModuleHandleExW(FROM_ADDRESS) succeeded for a VirtualAlloc page and returned a module above the address, so locate panicked on the subtraction in a test build. That was another fault inside the report. Such an address is now shown bare.

Tested

  • cargo clippy -p victory-loader --all-targets --locked -- -D warnings, with and without --all-features, cross-built for x86_64-pc-windows-msvc on Linux: clean.
  • cargo xtask policy: ok.
  • cargo test -p victory-loader under Wine 11.21: 35 passed, 1 failed. The failure is concurrent_crash_records_stay_together, which also fails 3 of 3 on base under Wine (Loader: keep concurrent crash records whole #3092).
  • New test a_fault_while_reporting_is_not_reported_again: a report whose own instruction-bytes read faults, with a later handler reopening the page. Under Wine 11.21 it fails without the flag (2 reports) and passes with it (1).
  • In the field I ran the same flag placed in handler rather than in report. This PR moves it into report so the unhandled filter is covered too.

Copilot AI balanced review requested due to automatic review settings November 27, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

A fault inside the crash report reached the vectored handler again on the
same thread, whose report faulted the same way, until the thread ran out
of stack. A thread-local flag in report() lets the nested exception go on
unreported, for both the vectored handler and the unhandled filter.
@oni-swr

oni-swr commented Nov 27, 2026

Copy link
Copy Markdown

Independent WARP/CPU verification of #3520 at head 771b5d68 (base: main 63bcca43, merge-base of this PR). Head re-checked unchanged just before posting.

Setup: Windows 11 Pro 10.0.26200, AMD Ryzen 7 5700X3D, VICTORY_WARP=1 VICTORY_D3D12_WARP=1 set, though this crate does not use the GPU. Base and head were built in separate worktrees with separate target dirs. Test command: cargo test -p victory-loader --features diagnostics.

lane base head
victory-loader (lib + crash_log + load_probe + title_dlls) 37 + 1 + 2 + 1 passed, 0 failed 37 + 1 + 2 + 1 passed, 0 failed

cargo clippy -p victory-loader --features diagnostics --all-targets -- -D warnings passes on the head and on base.

Diff review: no bug found.

  • The reentrancy guard is a const thread_local! Cell<bool> with no destructor, so reading it inside a fault or stack-overflow handler does not allocate or lazily register anything. try_with(..).unwrap_or(true) also skips reporting during thread teardown.
  • A nested fault returns early, so the exception goes on to the next handler. The first report is no longer lost to infinite recursion, and the flag is cleared after a normal return.
  • Nit: the PR adds no test. The existing tests pass, but nothing exercises the nested-fault path, so a regression would not be caught.

AI-assisted: Claude Code, Claude Sonnet 5.5.

a_fault_while_reporting_is_not_reported_again reports a synthetic
illegal instruction on an unreadable page: reading its bytes faults
inside the report, and a handler after ours reopens the page. One report
is made; without the flag, two.

Under Wine 11.21 GetModuleHandleExW(FROM_ADDRESS) succeeded for a page
from VirtualAlloc with a module above it, and locate panicked on the
subtraction (a test build). Such an address is shown bare.
@gkissel

gkissel commented Nov 27, 2026

Copy link
Copy Markdown
Author

Thanks for the independent run. I added the missing test in 4f58146.

a_fault_while_reporting_is_not_reported_again

  1. The test reports a synthetic illegal instruction whose address is on a PAGE_NOACCESS page.
  2. report reads the instruction bytes, so it faults inside itself.
  3. A vectored handler registered after ours reopens that page and continues.
  4. A test-only per-thread counter in report_once must read 1.

Run under Wine 11.21 (cross-built x86_64-pc-windows-msvc, cargo test -p victory-loader --lib):

  • with the flag disabled by a local edit: fails, left: 2, right: 1 (the nested fault was reported as well);
  • with the flag: passes.

Second fix in the same commit

Writing the test exposed another problem: under Wine 11.21, GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) succeeded for a page from VirtualAlloc and returned a module above that address. module_of then panicked on address - module with "attempt to subtract with overflow" in the test build, which is itself a fault inside the report. module_of now uses checked_sub and shows such an address bare.

Whole crate under Wine: 35 passed, 1 failed. The failure is concurrent_crash_records_stay_together. It fails 3 of 3 on base 63bcca4 as well (interleaved records under Wine, which #3092 addresses), so it is not caused by this PR.

Clippy with -D warnings is clean, with and without --all-features. cargo xtask policy is ok.

@cloph-dsp

Copy link
Copy Markdown

Independent CPU-only verification on Windows / Rust 1.100.0 / MSVC.

  • PR head: 4f581462233c48371a07fe14d453385bcda11b20, merge base 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • Command: cargo test --locked -p victory-loader --lib -- crash::tests::a_fault_while_reporting_is_not_reported_again --exact --test-threads=1 --quiet
  • Result: test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 35 filtered out, exit 0.
  • Negative control: git grep -F -c crash::tests::a_fault_while_reporting_is_not_reported_again 63bcca43 -- . → exit 1 / 0 hits (test genuinely new).
  • git diff --check 63bcca43 HEAD → exit 0.
  • Caveat: only the named synthetic VEH test was replayed; full crate suite and real crash-reporting under Wine were not exercised.
  • GPU/driver: N/A (CPU-only test). No game data, assets, extracted shaders or DRM involved.
  • AI-assisted: Hy4 flash.

@oddmaniv

Copy link
Copy Markdown

Independent verification of the PR author's concurrent WARP pipeline/draw test at 4f581462233c48371a07fe14d453385bcda11b20.

cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture

Tree Result
Unmodified PR head 1 passed, 0 failed, 0 ignored; native exit 0
Unmodified main 1 passed, 0 failed, 0 ignored; native exit 0
PR patch applied to pinned main 1 passed, 0 failed, 0 ignored; native exit 0

Main baseline pin: 63bcca43c6a00a758510398fa43096ce7e4f7df0.

Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.

AI-assisted verification.

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.

5 participants