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

Open
github-bot wants to merge 2 commits from github-bot/gh-586 into a-publier AGit
Owner

@⁠gkissel on GitHub · 2026-11-27 12:42 UTC · original
gkissel:crash-report-reentrancy → a-publier · +94 −1 · 1 files · 2 commits · open

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 the compiler guard here (VICTORY_COMPILER_GUARD; in my runs it did not catch the NVIDIA fault under Wine), Marvisak/VIctory#1897 (recovers a faulting RtlVirtualUnwind inside the walk), or Marvisak/VIctory#2401 (keeps a Wine compiler crash from ending the run). Those remove 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 --lib under Wine 11.21: 57 passed. The load_probe integration test could not build its fixture in my Linux cross-build (a Windows-style manifest path), unrelated to this change.
  • 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.

The same change is open upstream as Marvisak/VIctory#3520.

**@⁠gkissel** on GitHub · 2026-11-27 12:42 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/586) `gkissel:crash-report-reentrancy` → `a-publier` · +94 −1 · 1 files · 2 commits · open *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 the compiler guard here (`VICTORY_COMPILER_GUARD`; in my runs it did not catch the NVIDIA fault under Wine), Marvisak/VIctory#1897 (recovers a faulting `RtlVirtualUnwind` inside the walk), or Marvisak/VIctory#2401 (keeps a Wine compiler crash from ending the run). Those remove 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 --lib` under Wine 11.21: 57 passed. The `load_probe` integration test could not build its fixture in my Linux cross-build (a Windows-style manifest path), unrelated to this change. - 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. The same change is open upstream as Marvisak/VIctory#3520.
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:58:52 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 12:42 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-27 12:42 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/586#pullrequestreview-6088306290) · **reviewed** 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_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.
Author
Owner

@⁠DecayingEagle on GitHub · 2026-11-27 16:51 UTC · original

Independent Wine validation on RX 7900 XT / CachyOS, private Wine 11.22 (mapped-view lookup patch), Rust 1.98.1 MSVC cross-target, diagnostics enabled. The loader change matches 840e0e496f5a9150ff98e169861aa3c0fedbe96f; #569 was also present in the GPU crate.

  • Removing only the report reentry guard, while retaining the regression, reproduces the assertion: two reports instead of one.
  • Restoring the guard: the diagnostics-enabled loader library suite passes 65/65, including a_fault_while_reporting_is_not_reported_again.
  • Workspace/all-target Clippy, default and all features, -D warnings, and repository policy pass.

This verifies reporting behavior under Wine 11.22. It does not fix or explain our separate title-side null command-allocator access in #583. No game data attached.

Testing and report assisted by OpenAI Codex.

**@⁠DecayingEagle** on GitHub · 2026-11-27 16:51 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/586#issuecomment-7223742013) Independent Wine validation on RX 7900 XT / CachyOS, private Wine 11.22 (mapped-view lookup patch), Rust 1.98.1 MSVC cross-target, diagnostics enabled. The loader change matches `840e0e496f5a9150ff98e169861aa3c0fedbe96f`; #569 was also present in the GPU crate. - Removing only the `report` reentry guard, while retaining the regression, reproduces the assertion: two reports instead of one. - Restoring the guard: the diagnostics-enabled loader library suite passes **65/65**, including `a_fault_while_reporting_is_not_reported_again`. - Workspace/all-target Clippy, default and all features, `-D warnings`, and repository policy pass. This verifies reporting behavior under Wine 11.22. It does not fix or explain our separate title-side null command-allocator access in #583. No game data attached. Testing and report assisted by OpenAI Codex.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/586/head:github-bot/gh-586'
git switch 'github-bot/gh-586'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-586'
git switch 'github-bot/gh-586'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-586'
git switch 'github-bot/gh-586'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-586'
git switch 'a-publier'
git merge --squash 'github-bot/gh-586'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-586'
git switch 'a-publier'
git merge 'github-bot/gh-586'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.