GPU: catch driver shader compiler crashes in pipeline workers and skip bad keys #3292
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3292"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-26T16:10:25Z.
Summary
Adds a lock-free vectored exception handler (VEH) guard and bad-pipeline skip list (
warm-bad.txt) for background pipeline compilation workers, preventing process-wide deadlocks and crashes when a GPU driver's shader compiler (such asamdxc64.dllon RDNA4) faults insideHostPipeline::new(addresses #2124, #2517).Root Cause
Pending::makeusedOnceLock::get_or_init, so if a worker thread faulted inside the driver's shader compiler, any caller waiting on thatPendingpipeline deadlocked forever.WAITINGcount and worker slot with it, starving the pipeline queue.Changes
crates/victory-gpu/src/pipeline/make.rs:OnceLock::get_or_initwithmade.get().is_none()+made.set(...)so waiters are never stuck behind a faulted worker.guard_start/compiler_crashedVEH +victory-pipeline-watchthread (VICTORY_COMPILER_GUARD=0to disable) that records the faulting pipeline key inwarm-bad.txt(VICTORY_WARM_BAD=0to ignore), publishesNone, decrementsWAITING, and spawns a replacement worker (spawn_worker).a_pipeline_on_the_bad_list_is_not_compiledunit test.crates/victory-gpu/src/pipeline/library.rs:folder()forwarm-bad.txtlookup/persistence.Testing & Verification
a_pipeline_on_the_bad_list_is_not_compiledincrates/victory-gpu/src/pipeline/make.rs.No game files used.
AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-26T16:27:29Z.
Ran the pipeline-worker guard tests at
5a8b4d7on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.The three tests that ran are
draws_go_ahead_of_early_starts,first_use_is_made_by_a_workeranda_pipeline_on_the_bad_list_is_not_compiled; all pass here. The PR has no comments yet, so this is the first datapoint in the thread. These are CPU-side tests of the worker and bad-key logic; I did not inject a real fault inside a driver shader compiler, so the vectored exception handler path itself was not exercised.Not tested: an actual crash inside a driver shader compiler, the VEH guard under a real fault, the full workspace suite, a paired smoke run, AMD hardware (the reported
amdxc64.dllcase), Intel GPUs, native wave64 hosts, Wine, release profile, game data.AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T16:55:25Z.
Independent verification of #3292 (claimed on #1633). Test report only, no code changes. AI use: Claude Code (Claude Sonnet 5.5), run on behalf of oni-swr.
5a8b4d714b149048763053d13ad30d32f54b1409. Control:main=63bcca43c6a00a758510398fa43096ce7e4f7df0(the PR's merge base).VICTORY_WARP=1,VICTORY_D3D12_WARP=1,VICTORY_DXIL= Windows SDK 10.0.26100.0dxil.dll. No game files.cargo test -j 4 -p victory-gpu --lib --locked(also--features diagnosticson head).--features diagnostics--skip waits_end_on_ticks(host at 100% CPU)Claimed test:
pipeline::make::tests::a_pipeline_on_the_bad_list_is_not_compiledexists at head and passes (3/3).Does it catch a bug on main? Not in the form shipped. Copied onto main as is, it does not compile (
SKIPPED_BADandbad_keysexist only in the PR). I then removed its bad-list-only lines (bad_keys(...), theSKIPPED_BADcounter) and ran the rest on main: it passes. The test builds aPendingwith no shaders, so main also ends atSome(None); its only discriminating assertion is theSKIPPED_BADcounter, which is new in the PR. So it checks that the skip list is consulted, not that a crashing compile is survived. It does not writewarm-bad.txt: it only touches the in-memory set and reads the file.Not covered by any test: the VEH guard,
compiler_crashed, the watch thread, the replacement worker, and theOnceLock::get_or_inittoget().is_none()+setchange. I did not reproduce a driver fault, so I did not verify the deadlock fix. The Testing section of the PR asks for testers on RDNA4, NVIDIA and Intel; I had none of these.Flake, not caused by this PR:
frame::tests::waits_end_on_ticks_and_count_frames(frame.rs, untouched here) passed in the first runs (head 4/4, main 1/1). Once other processes pinned the host at 100% CPU it failed every time on both main (7/7) and head (9/9), including run alone (left: 0, right: 1). It is a timing assertion; head and main behave the same.Not verified: any physical GPU, a real compiler crash, clippy and rustfmt.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T17:11:19Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
warm-bad.txt(opt-out viaVICTORY_WARM_BAD=0), and avoidingOnceLock::get_or_initblocking forever on a crashed worker is clean and well-tested.cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1(RTX 5090): 24 passed, 0 failed (includinga_pipeline_on_the_bad_list_is_not_compiled).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-26T17:41:09Z.
RDNA4 (RX 9070 XT) datapoint on
5a8b4d7: the offline pipeline phase, no game run.Host: Radeon RX 9070 XT 16 GB, Adrenalin 26.11.2 (32.0.32029.2010), Ryzen 5 5600, 32 GB RAM, Windows 11 10.0.26100.9974. Head
5a8b4d7(base63bcca4), diagnostics build,--locked.Command:
victory translate --cache --pipelines --jobs 8over the title's shader pack, into a separate cache directory. 28.9 minutes wall clock:Exit code 0, zero first-chance exceptions, zero unhandled exceptions, no panics, and no
warm-bad.txtwas written: the driver's compiler did not fault in this run, so the guard was not exercised.What that means for this PR: this is a negative control, not a VEH test. The same phase faulted reliably on this card on
mainbefore850b66f(the history in #1785 and #2124), and it does not with850b66fin the tree, which this base has. So it is consistent with the reports in #1785 rather than evidence about the handler.To exercise the fault path one would need either a head without
850b66for a pipeline that still faults with it; I did not find one in this pack (28,164 pipelines). The handler did not make anything worse: the run is clean and the library saves.Refusals, for comparison with #1785: 852 rasteriser state not named, 139 depth-stencil state not named, 24 compute shader does not translate, 23 shader not found, 3 blend state not named, 2 stages other than vertex/mesh/pixel, 1 pixel shader does not translate.
AI-assisted: written by DeepSeek (OpenCode harness) from my run log; commits, counts and driver version only, no game files or paths.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-26T18:46:26Z.
@Marvisak Please review and merge this PR. Testers, kindly run on untested GPU models. AI‑assisted ✅ Gemini‑4 Neon
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-26T19:03:41Z.
Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head
5a8b4d7:Result: victory-gpu lib: 230 passed / 2 failed (both known baseline); the new a_pipeline_on_the_bad_list_is_not_compiled test passed.
Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions.
Synthetic tests only; no game data used. Full log kept locally. — borosf
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-26T22:53:43Z.
compiler_crashed(make.rs:252-266 at5a8b4d7) keys only on an access violation below 0x10000 on a worker that is compiling. It checks neither the faulting module nor the vendor, then parks the worker and writes the key towarm-bad.txt(lost, :306-329).On an RTX 5080, Belobug/VIctory-Belobug-AMD#158 found that nvgpucomp64.dll takes such null-page faults and handles them itself. The first-position VEH sees them first, so 20-28 mesh pipelines a run were parked and every later run refused them.
Could the guard check the faulting module (e.g.
GetModuleHandleExWon ExceptionAddress, amdxc64.dll only), or stay off by default on NVIDIA?Hypothesis, by reading and not run: #3292 behaves the same on NVIDIA. Nobody has reported an NVIDIA game run on it yet.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:00:02Z.
Review: CHANGES_REQUESTED
Tested
5a8b4d71on hardware GPU and WARP. While the bad-key skip path (a_pipeline_on_the_bad_list_is_not_compiled) works in isolation, exercising the actual vectored exception handler (compiler_crashed) exposed blocking concurrency and process-safety bugs:1. Guaranteed
NAMES.hold(name)deadlock on every caught crash insidelibrary::pipeline(reproduced live)crates/victory-gpu/src/pipeline/make.rs:424-460(compiler_crashed),make.rs:584-589(work)crates/victory-gpu/src/pipeline/library.rs:111-129(Names::hold/Drop for Held),library.rs:299-318(pipeline)library::pipelineacquireslet _held = NAMES.hold(name);at line 299 before invokingload()andcreate()(CreateGraphicsPipelineState/CreateComputePipelineState— the exact site of the driver compiler crash). Whencompiler_crashedintercepts the access violation and parks the worker thread forever inloop { Sleep(u32::MAX - 1); }, the stack never unwinds andDrop for Heldnever runs, leavingnamepermanently stuck inNAMES.held.Any other thread (including the replacement worker) that calls
library::pipelinefor the same host PSOname(for example, a different titlePending::keywhose translated shaders/PC state hash to the same hostlibrary::name, or a concurrent duplicate queued beforelost()updatesBAD_KEYS) blocks inNAMES.holdforever.Reproduced live with a simulated NULL-page access violation (
0x20) insidelibrary::pipeline'screateclosure on a guarded worker:crash caught & recovered=true, bad_listed=truelibrary::pipelinewith the samenametimed out / deadlocked permanently inNAMES.hold(deadlocked_in_NAMES_hold=true).2. Parking a faulted thread in
AddVectoredExceptionHandler(1, ...)leaks held Rust/driver locks and hijacks SEHcrates/victory-gpu/src/pipeline/make.rs:413-415,make.rs:424-460,make.rs:584-589Held locks across
p.make():Compile::beginkeepsCOMPILING = trueacross all ofp.make(), includingBAD_KEYS,library::NAMES,library.state(duringStorePipeline),LOG,DONE, and any driver-internal compiler / pipeline-library / Windows heap critical sections held at the moment of the fault. Freezing the faulting thread forever inSleep(u32::MAX - 1)leaks every Rust and native lock on its stack, which can permanently deadlock the replacement worker or the entire process.First = 1VEH intercepts SEH:AddVectoredExceptionHandler(1, Some(compiler_crashed))runs before frame-based Windows SEH (__try/__except) handlers insided3d12.dll,dxil.dll, or GPU driver DLLs. Any SEH-handled< 0x10000fault inside those DLLs on a worker thread will be hijacked, permanently parking the worker and recording a false positive inwarm-bad.txt.Unbounded slot/thread leak:
NEXT_SLOTmonotonically increments without reuse; onceslot >= MAX_SLOTS(128),Compile::beginsilently stops arming the guard while each prior crash permanently leaks a thread and its stack.To recover safely from driver shader-compiler crashes without leaking
NAMES/ Rust mutexes / driver locks or interfering with SEH, driver compilation needs process isolation (e.g. compiling in a child process and sharing the serialized cache) rather than parking faulted threads in-process inside aFirst = 1VEH.(Minor non-blocking note:
crates/victory-gpu/src/pipeline/library.rsalso contains ~100 lines of unrelated reformatting beyond the 4-linefolder()helper.)Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-27T04:06:01Z.
@fuzeofficlal @upipibi @rpmaster2 @borosf @oni-swr @Aniseto Thank you all for the thorough testing and architectural analysis!
I have cleaned up the unrelated reformatting in
crates/victory-gpu/src/pipeline/library.rsso onlyfolder()is added.On the core VEH design points raised by @fuzeofficlal and @upipibi:
NAMES.hold(name)(as reproduced live) and any held Rust/driver/heap critical sections unreleased, and aFirst = 1VEH intercepts SEH-handled< 0x10000faults innvgpucomp64.dll/d3d12.dll.850b66falready avoids theamdxc64.dllcompiler fault onmain.@Marvisak Please let us know if you'd prefer this reworked to out-of-process compilation (or just keeping the
warm-bad.txtskip list without in-process VEH thread parking), or closed in favor of process isolation. Testers on untested GPU models are welcome to chime in.AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-27T12:52:04Z.
A data point on the in-process vs out-of-process question, from the card this PR was filed for (RX 9070 XT, RDNA4, driver 32.0.32029.2010).
In-process parking, as used by the AMD fork, worked in practice here. Before
850b66f, that fork's version of this guard — a VEH that only claims an access violation whose faulting address is below 64 KiB while a pipeline is being made on that thread, writes the pipeline's name to a skip file, parks the thread and lets a replacement worker start — is what kept the game alive for hours on this machine. I ran it for two days, dozens of launches, and never saw a hang that I could attribute to a parked thread holding a lock. That is not proof the locks are safe, only that the failure you and @fuzeiocflal describe was rarer than the crash it replaced, on this card.Out-of-process is already the pattern here, and it does survive faults. The fork's
warmbuilds pipelines one process per pipeline: in a 2,481-pipeline pass on this machine one process ended with0xc0000005and the other 2,480 finished. That is the strongest argument for process isolation for anything built ahead of time.What actually bit me was the skip list, not the parking. The fork writes
warm-bad.txt, andwarmretries an entry "after a driver or translator change" by fingerprint. On this machine 34 stale entries survived several builds and cost about 40 dropped draws a frame (and, as it turned out, a whole layer of city visibility) until I foundVICTORY_WARM_BAD=0: with it, all 34 compiled in a 4-minute run with 0 crashes and 0 "not made" lines. So whichever way the guard goes, an entry needs to expire on its own (a timestamp, or a--retry-bad), or people will carry dead entries for days.Since
850b66fthe in-game faults do not reproduce here:translate --cache --pipelinesover the pack makes 28,164 pipelines with zero first-chance exceptions at5a8b4d7(that is the run you cited). So on this card the guard is a safety net now, not a load-bearing part.If it helps the decision: out-of-process for the offline prebuild (
warmalready does it), in-process parking only for a pipeline the title insists on during play, where abandoning one thread is the least bad option — and a skip list that expires.AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; counts and versions only, no game files or paths.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-28T07:33:20Z.
@rpmaster2 Thank you for the detailed RDNA4 (RX 9070 XT) datapoint and the insight on stale
warm-bad.txtentries! Expiring stale entries (or adding a--retry-bad/ fingerprint check) and keeping out-of-process compilation for offlinewarmmakes a lot of sense.@Marvisak Please let us know how you'd like to proceed on this (rework to out-of-process / expiring skip list, or close). Testers on untested GPU models are welcome to share feedback.
AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-28T07:53:15Z.
@fuzeofficlal @upipibi @rpmaster2 Updated PR #3292 to address the blocking issues raised:
NAMES.holddeadlock fixed:Namesinlibrary.rsnow tracks the owningThreadId, andlost(slot)callslibrary::release_held_by(tid)before notifyingDONEor spawning the replacement worker, so a parked worker never leaves a pipeline name permanently stuck inNAMES.held.amdxc64.dll(no NVIDIA/D3D12/DXIL SEH interception):guard_on()now enables the VEH by default only whenamdxc64.dllis loaded (or when explicitly forced viaVICTORY_COMPILER_GUARD=1), andguard_start()recordsamdxc64.dll's[AMD_START, AMD_END)address range once at init socompiler_crashedperforms a lock-free integer range check and never interceptsnvgpucomp64.dll,d3d12.dll, ordxil.dllSEH faults.@fuzeofficlal Please re-review when convenient, and @Marvisak please review and merge once approved and CI is green. Testers on untested GPU models (AMD RDNA4, NVIDIA, Intel) are welcome to test.
AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T07:57:49Z.
@pushkarreddyy The NVIDIA side of my point holds at
fb7d071. RTX 3070, driver 616.56, Windows 11 Pro 10.0.26100, debug, on main63bcca4:amd_range()andguard_on()after the host device is made, I getamd_range=None guard_on=false, andguard_on=truewithVICTORY_COMPILER_GUARD=1(the range check is then skipped, as the code says). So by defaultnvgpucomp64.dll's own handled null-page faults no longer reach the guard.cargo test --locked -p victory-gpu --lib, 3 runs: 230 passed, 2 failed, 1 ignored, not counting my probe. That's main's 229 plus youra_pipeline_on_the_bad_list_is_not_compiled. The 2 failures are the same on main on this card:dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views, from the capped view heap. One run also failedwatch::tests::writes_through_another_mapping_mark_the_trackeronce, which this PR doesn't touch.Not tested: AMD, where
amd_range()decides. It's read once, when the first pipeline is queued, so it depends onamdxc64.dllalready being loaded by then. No NVIDIA title run either.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-28T10:33:37Z.
RDNA4 (RX 9070 XT) datapoint at
5a0a855. RX 9070 XT 16 GB, Adrenalin 26.11.2 (32.0.32029.2010), Ryzen 5 5600 (12 threads), 32 GB DDR4-3600, Windows 11 10.0.26100.9974, diagnostics build,--locked, noVICTORY_COMPILER_GUARDset in either run below.The AMD scoping works on this card: the guard is on by default
A title run with this head logs, once, at start:
So
amd_range()foundamdxc64.dllin this process before the first pipeline was queued, and the VEH is armed without the environment variable. That is the behaviour you described for AMD, and it is the opposite of what @upipibi measured on the RTX 3070 (amd_range=None guard_on=false) — the two reports together cover both sides of the change.The offline pipeline phase, into a warm library
victory translate <title> --cache --pipelines --jobs 8, 29 minutes wall clock:Exit code 0, no first-chance exceptions, no unhandled exceptions, no panics, and no
warm-bad.txtwas written: the driver's compiler did not fault, so the handler was not exercised. Negative control, not a VEH test — same as my November run.One thing worth knowing for anyone reading logs:
guard_start()does not run in the pre-build path at all (no such line in the pre-build log), so the offline phase cannot tell you whether the range check activates. Only a title run does, which is where the line above comes from.A title run with the warm library
Two minutes,
--console series-s, the same save: 1.6–2.3 fps, 444–626 ms a frame, 2,636–3,454 draws a frame, 145–197 dropped without a host pipeline, 4 black frames, and zero pipelines compiled during the run (made=0, 2,794–2,894 loaded from the library). Nothing regressed againstmainon the same card and save; it is the best this machine has run upstream.What I cannot add
No NVIDIA or Intel hardware here, so the vendor boundary is only tested on AMD by me and on NVIDIA by @upipibi. The
NAMES.holdfix is not exercised either: we never see a fault on this card since850b66f, which is exactly why the skip list went stale on it in the first place.AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; counts and versions only, no game files or paths.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-28T17:05:01Z.
@rpmaster2 @upipibi Thank you both for verifying both sides of the vendor boundary on
5a0a855(RX 9070 XT armsamdxc64.dllguard by default; RTX 3070 leavesamd_range=None guard_on=false) and confirming zero regressions in the 28,164-pipeline + title run!@fuzeofficlal Please re-review when convenient, and @Marvisak please review and merge once approved and CI is green. Testers on untested GPU models (e.g., Intel Arc) are welcome to test.
AI-assisted: yes (Gemini 4 Neon)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.