GPU diagnostics: a pipeline whose creation faults is refused and the title goes on (opt-in, on #491) #2290

Open
desplmfao wants to merge 27 commits from upstream-pr/2292 into main
desplmfao commented 2026-11-25 10:03:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T10:03:57Z.


Stacked on #491 (the pipeline journal). Its commits come first here; the change is the last commit, a690518.

Problem

Under Wine/vkd3d-proton, creating a host pipeline runs dxil-spirv and then the driver's compiler inside the title's process. On some translated shaders, one of them faults. Examples here: dxil-spirv recursing about 100k frames on #439's loop shapes, and NVIDIA's compiler crashing on others. A single bad pipeline ends the run. #491 then refuses it from the next run on, but that is one restart per bad pipeline.

Change

Opt-in, with VICTORY_PIPELINE_SOFT_CRASH=1:

  • The guard. Pipeline creation on the pipeline workers runs inside a guard (pipeline/soft_crash.rs). That covers both Load*Pipeline and Create*PipelineState.
    • A vectored exception handler acts only on an armed worker that is inside the guarded call, and only for fault-kind exceptions: access violation, illegal instruction, stack overflow and the like. Software exceptions, heap corruption (0xC0000374) and stack-buffer overrun (0xC0000409) are left alone.
    • On a fault it resumes at a small assembly frame (with SEH unwind data) that saved the callee-saved registers, MXCSR and the x87 control word. The call then returns the exception code. Rust never "returns twice": only the frames below the assembly frame are abandoned. Panics are caught inside the guard and raised again after it.
  • A faulted pipeline is refused for the rest of the run, whether or not the journal is on. Its draws and dispatches are dropped. One error line gives its shader hashes, stages, the code and the address. With the journal on, it goes into crashed.txt immediately, in the existing format plus (fault 0x…), so later runs refuse it too.
  • The worker that faulted exits and a new one replaces it, since its stack may have lost its guard page. Armed workers call SetThreadStackGuarantee(64 KiB) so the handler has stack left after an overflow. Pipeline workers get a 256 MiB stack, which is reserved, not committed.
  • After 8 caught faults the guard stops catching. From then on a fault ends the process as before, and the journal names the pipeline at the next start.

Risks

This is why it is opt-in:

  • A lock held by vkd3d-proton or the driver at the fault stays held. Later creations that need it wait, and pipelines stop arriving while drawing goes on.
  • Memory allocated by the abandoned frames is leaked. A fault caused by an already corrupted heap leaves it corrupted.
  • The vectored handler runs before the host's own handlers, but only for an armed thread inside the guarded call.
  • Under Wine, an overflow that leaves too little stack to raise the exception is aborted by Wine itself (virtual_setup_exception stack overflow). The guard can't catch that one; the bigger stack makes it less likely.
  • #1885 and #1129 also enlarge the pipeline worker stack in make.rs (256 and 64 MiB). Expect a one-line conflict; I can drop the stack part here if #1885 lands.
  • #151 (a 16 MiB default stack via the linker) is complementary.
  • #1972 (find crashing pipelines offline) and #1320 (VICTORY_SKIP_PIPELINES) have the same goal by different means.

Tested

RTX 5080, Linux, Proton with vkd3d-proton 3.2.0:

  • cargo test -p victory-gpu --lib soft_crash: 6 passed. They cover an access violation (0xC0000005), an illegal instruction (0xC000001D), a deep-recursion stack overflow on a 1 MiB thread (0xC00000FD), values and panics passing through, threads that aren't armed staying unguarded, and the fault-kind filter.

  • cargo test -p victory-gpu --lib journal: 8 passed, including a_pipeline_whose_creation_faulted_is_refused_now_and_in_later_runs.

  • cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without --features diagnostics: clean.

  • In the title. The build was our stack with #439 but without #2309. There, vkd3d-proton's dxil-spirv recurses until the stack runs out on two of #439's programs, and before this change that ended the process. Run under Proton, with vkd3d-proton 3.2.0, VICTORY_PIPELINE_SOFT_CRASH=1 and VICTORY_PIPELINE_JOURNAL=1:

    WARN victory_gpu::pipeline::soft_crash: VICTORY_PIPELINE_SOFT_CRASH: a pipeline whose creation faults is refused and the run goes on; locks or memory the host held then may be lost limit=8
    ERROR victory_gpu::pipeline::journal: creating this host pipeline faulted; it is refused, its draws and dispatches dropped, and the run goes on pipeline="32ed072b9f845048" stages="compute-3360" code=0xc00000fd address=0x6ffff0a182f5 listed=true
    ERROR victory_gpu::pipeline::journal: creating this host pipeline faulted; it is refused, its draws and dispatches dropped, and the run goes on pipeline="fdd56d97a806bcca" stages="compute-8540" code=0xc00000fd address=0x6ffff09aa2b1 listed=true
    

    Both are stack overflows (0xc00000fd) inside vkd3d-proton under Wine, caught 10 s into the run. 383 more pipelines were created after the second one, so no host lock was lost. The title kept running until I stopped it 90 s later. crashed.txt lists both, each with a # compute-… (fault 0xc00000fd) comment.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5489166026 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2292). Originally posted by [desplmfao](https://github.com/desplmfao) on 2026-11-25T10:03:57Z. --- **Stacked on #491** (the pipeline journal). Its commits come first here; the change is the last commit, `a690518`. ## Problem Under Wine/vkd3d-proton, creating a host pipeline runs dxil-spirv and then the driver's compiler inside the title's process. On some translated shaders, one of them faults. Examples here: dxil-spirv recursing about 100k frames on #439's loop shapes, and NVIDIA's compiler crashing on others. A single bad pipeline ends the run. #491 then refuses it from the next run on, but that is one restart per bad pipeline. ## Change Opt-in, with `VICTORY_PIPELINE_SOFT_CRASH=1`: - **The guard.** Pipeline creation on the pipeline workers runs inside a guard (`pipeline/soft_crash.rs`). That covers both `Load*Pipeline` and `Create*PipelineState`. - A vectored exception handler acts only on an armed worker that is inside the guarded call, and only for fault-kind exceptions: access violation, illegal instruction, stack overflow and the like. Software exceptions, heap corruption (`0xC0000374`) and stack-buffer overrun (`0xC0000409`) are left alone. - On a fault it resumes at a small assembly frame (with SEH unwind data) that saved the callee-saved registers, MXCSR and the x87 control word. The call then returns the exception code. Rust never "returns twice": only the frames below the assembly frame are abandoned. Panics are caught inside the guard and raised again after it. - **A faulted pipeline is refused for the rest of the run**, whether or not the journal is on. Its draws and dispatches are dropped. One error line gives its shader hashes, stages, the code and the address. With the journal on, it goes into `crashed.txt` immediately, in the existing format plus `(fault 0x…)`, so later runs refuse it too. - **The worker that faulted exits and a new one replaces it**, since its stack may have lost its guard page. Armed workers call `SetThreadStackGuarantee(64 KiB)` so the handler has stack left after an overflow. Pipeline workers get a 256 MiB stack, which is reserved, not committed. - **After 8 caught faults the guard stops catching.** From then on a fault ends the process as before, and the journal names the pipeline at the next start. ## Risks This is why it is opt-in: - A lock held by vkd3d-proton or the driver at the fault stays held. Later creations that need it wait, and pipelines stop arriving while drawing goes on. - Memory allocated by the abandoned frames is leaked. A fault caused by an already corrupted heap leaves it corrupted. - The vectored handler runs before the host's own handlers, but only for an armed thread inside the guarded call. - Under Wine, an overflow that leaves too little stack to raise the exception is aborted by Wine itself (`virtual_setup_exception stack overflow`). The guard can't catch that one; the bigger stack makes it less likely. ## Related - #1885 and #1129 also enlarge the pipeline worker stack in `make.rs` (256 and 64 MiB). Expect a one-line conflict; I can drop the stack part here if #1885 lands. - #151 (a 16 MiB default stack via the linker) is complementary. - #1972 (find crashing pipelines offline) and #1320 (`VICTORY_SKIP_PIPELINES`) have the same goal by different means. ## Tested RTX 5080, Linux, Proton with vkd3d-proton 3.2.0: - `cargo test -p victory-gpu --lib soft_crash`: 6 passed. They cover an access violation (`0xC0000005`), an illegal instruction (`0xC000001D`), a deep-recursion stack overflow on a 1 MiB thread (`0xC00000FD`), values and panics passing through, threads that aren't armed staying unguarded, and the fault-kind filter. - `cargo test -p victory-gpu --lib journal`: 8 passed, including `a_pipeline_whose_creation_faulted_is_refused_now_and_in_later_runs`. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`, with and without `--features diagnostics`: clean. - **In the title.** The build was our stack with #439 but **without** #2309. There, vkd3d-proton's dxil-spirv recurses until the stack runs out on two of #439's programs, and before this change that ended the process. Run under Proton, with vkd3d-proton 3.2.0, `VICTORY_PIPELINE_SOFT_CRASH=1` and `VICTORY_PIPELINE_JOURNAL=1`: ``` WARN victory_gpu::pipeline::soft_crash: VICTORY_PIPELINE_SOFT_CRASH: a pipeline whose creation faults is refused and the run goes on; locks or memory the host held then may be lost limit=8 ERROR victory_gpu::pipeline::journal: creating this host pipeline faulted; it is refused, its draws and dispatches dropped, and the run goes on pipeline="32ed072b9f845048" stages="compute-3360" code=0xc00000fd address=0x6ffff0a182f5 listed=true ERROR victory_gpu::pipeline::journal: creating this host pipeline faulted; it is refused, its draws and dispatches dropped, and the run goes on pipeline="fdd56d97a806bcca" stages="compute-8540" code=0xc00000fd address=0x6ffff09aa2b1 listed=true ``` Both are stack overflows (`0xc00000fd`) inside vkd3d-proton under Wine, caught 10 s into the run. 383 more pipelines were created after the second one, so no host lock was lost. The title kept running until I stopped it 90 s later. `crashed.txt` lists both, each with a `# compute-… (fault 0xc00000fd)` comment. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
catminou4 commented 2026-11-25 10:19:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:10Z.

Review: COMMENTED


GPU diagnostics: VICTORY_PIPELINE_JOURNAL crash journal — a pipeline whose creation faults is refused next run, suspects isolated one-by-one (+1034 incl. README). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Ambitious self-healing for driver crashes; the 'quit during single creation looks like a crash' caveat is honest. Windows-only path.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055712020 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2292#pullrequestreview-6055712020). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:10Z. **Review:** COMMENTED --- GPU diagnostics: VICTORY_PIPELINE_JOURNAL crash journal — a pipeline whose creation faults is refused next run, suspects isolated one-by-one (+1034 incl. README). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Ambitious self-healing for driver crashes; the 'quit during single creation looks like a crash' caveat is honest. Windows-only path.
desplmfao commented 2026-11-25 12:03:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T11:21:21Z.


Out of draft: it has now caught real faults in the title. Our stack with #439 but without #2309 has two programs on which vkd3d-proton's dxil-spirv recurses until the stack runs out (32ed072b9f845048, fdd56d97a806bcca); before, the process ended there. With VICTORY_PIPELINE_SOFT_CRASH=1, both were caught as 0xc00000fd 10 s into the run, refused, and listed in crashed.txt. 383 more pipelines were created after them, so no lock was lost, and the title kept running until I stopped it. Log lines are in the description.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160936232 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2292#issuecomment-7160936232). Originally posted by [desplmfao](https://github.com/desplmfao) on 2026-11-25T11:21:21Z. --- Out of draft: it has now caught real faults in the title. Our stack with #439 but without #2309 has two programs on which vkd3d-proton's dxil-spirv recurses until the stack runs out (`32ed072b9f845048`, `fdd56d97a806bcca`); before, the process ended there. With `VICTORY_PIPELINE_SOFT_CRASH=1`, both were caught as `0xc00000fd` 10 s into the run, refused, and listed in `crashed.txt`. 383 more pipelines were created after them, so no lock was lost, and the title kept running until I stopped it. Log lines are in the description.
Marvisak commented 2026-11-25 14:07:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:32:53Z.


Automated triage for the maintainers.

Needs work: needs the maintainer's decision (re-checked on f33dd8b). The merge of main resolves the earlier conflicts, so this merges cleanly again. The PR's own part is unchanged:

  • pipeline/soft_crash.rs: an opt-in (VICTORY_PIPELINE_SOFT_CRASH=1) vectored exception handler plus a global_asm! frame with SEH unwind data, which resumes a pipeline worker after a fault in the host compiler;
  • make.rs: the spawn_worker replacement thread with a 256 MiB reserved stack;
  • one README row.

The faulted pipeline is refused and the worker is replaced. Handler and frame are scoped to armed workers inside the guarded call, fault-kind codes only, at most 8 faults per run. Whether VIctory should carry this unsafe surface (locks held at the fault stay held, abandoned frames leak) is the maintainer's call, as noted before.

The PR is still stacked on #491 (open), so journal.rs and its README row belong to that review. Once #491 lands, this PR should shrink to soft_crash.rs, the make.rs worker changes and one README row.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163935407 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2292#issuecomment-7163935407). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:32:53Z. --- <!-- victory-triage v1 head=f33dd8b7386216218c2c2be46a826b4d8f2d9098 verdict=needs-work at=2026-11-26T01:25:29Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision (re-checked on `f33dd8b`).** The merge of `main` resolves the earlier conflicts, so this merges cleanly again. The PR's own part is unchanged: - `pipeline/soft_crash.rs`: an opt-in (`VICTORY_PIPELINE_SOFT_CRASH=1`) vectored exception handler plus a `global_asm!` frame with SEH unwind data, which resumes a pipeline worker after a fault in the host compiler; - `make.rs`: the `spawn_worker` replacement thread with a 256 MiB reserved stack; - one README row. The faulted pipeline is refused and the worker is replaced. Handler and frame are scoped to armed workers inside the guarded call, fault-kind codes only, at most 8 faults per run. Whether VIctory should carry this unsafe surface (locks held at the fault stay held, abandoned frames leak) is the maintainer's call, as noted before. The PR is still stacked on #491 (open), so `journal.rs` and its README row belong to that review. Once #491 lands, this PR should shrink to `soft_crash.rs`, the `make.rs` worker changes and one README row. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
desplmfao commented 2026-11-25 14:07:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T13:39:56Z.


Merged #491's new head (3d6521b) in ba6356c. crashed.txt now names the translator its pipelines crashed under, so a pipeline listed here after a fault is tried again, alone, once the translator changes. The only conflict was journal.rs: I kept both module notes, and the soft-crash test now passes the translator to Journal::open and expects the header line.

I checked the merged code in Grand Theft Auto VI on Linux (RTX 5080) with two runs:

  • CS_Prop_BatchNoCull and CS_LaserLightShadowRaytracing listed under an old translator: both were tried again alone and made, and the list was reset to the current translator.
  • The same two listed under the current translator: both were still skipped.

pipeline::journal passes under Wine. pipeline::library::tests::a_rejected_blob_gives_an_empty_library fails under vkd3d-proton on this head and on e543c44 alike, so that one isn't from this merge.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7164109446 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2292#issuecomment-7164109446). Originally posted by [desplmfao](https://github.com/desplmfao) on 2026-11-25T13:39:56Z. --- Merged #491's new head (`3d6521b`) in `ba6356c`. `crashed.txt` now names the translator its pipelines crashed under, so a pipeline listed here after a fault is tried again, alone, once the translator changes. The only conflict was `journal.rs`: I kept both module notes, and the soft-crash test now passes the translator to `Journal::open` and expects the header line. I checked the merged code in Grand Theft Auto VI on Linux (RTX 5080) with two runs: - `CS_Prop_BatchNoCull` and `CS_LaserLightShadowRaytracing` listed under an old translator: both were tried again alone and made, and the list was reset to the current translator. - The same two listed under the current translator: both were still skipped. `pipeline::journal` passes under Wine. `pipeline::library::tests::a_rejected_blob_gives_an_empty_library` fails under vkd3d-proton on this head and on `e543c44` alike, so that one isn't from this merge.
desplmfao commented 2026-11-25 15:04:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T14:42:44Z.


Thanks for the triage.

  • README: done in 17a48d9. The two paragraphs are now one row in the variables table.
  • Reviewing the journal on its own: it already is its own PR, #491 (currently a merge candidate). This PR is stacked on it, and because it targets main, its diff shows #491's journal.rs too. Once #491 is in, this PR comes down to soft_crash.rs, the worker spawn in make.rs, and the README row.
  • The unsafe surface: understood that it's your call. It stays opt-in, and all the handler does is turn a fault inside pipeline creation into a refused pipeline. For what it's worth, it caught two real faults in Grand Theft Auto VI on Linux, and today it let us re-test those two pipelines with a cold cache without losing runs.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7165696612 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2292#issuecomment-7165696612). Originally posted by [desplmfao](https://github.com/desplmfao) on 2026-11-25T14:42:44Z. --- Thanks for the triage. - **README:** done in `17a48d9`. The two paragraphs are now one row in the variables table. - **Reviewing the journal on its own:** it already is its own PR, #491 (currently a merge candidate). This PR is stacked on it, and because it targets `main`, its diff shows #491's `journal.rs` too. Once #491 is in, this PR comes down to `soft_crash.rs`, the worker spawn in `make.rs`, and the README row. - **The unsafe surface:** understood that it's your call. It stays opt-in, and all the handler does is turn a fault inside pipeline creation into a refused pipeline. For what it's worth, it caught two real faults in Grand Theft Auto VI on Linux, and today it let us re-test those two pipelines with a cold cache without losing runs.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2292:upstream-pr/2292'
git switch 'upstream-pr/2292'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2292'
git switch 'upstream-pr/2292'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2292'
git switch 'upstream-pr/2292'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2292'
git switch 'main'
git merge --squash 'upstream-pr/2292'
git switch 'main'
git merge --ff-only 'upstream-pr/2292'
git switch 'main'
git merge 'upstream-pr/2292'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2290
No description provided.