d3d12: catch the driver's compiler crashing on a pipeline and carry on #3222
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3222"
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 ubiquitarianism/leonida. Originally posted by roanh47 on 2026-12-02T20:37:05Z.
Claim
claiming: AMD compiler crash guard on RDNA4 (LEONIDA_COMPILER_GUARD)What this does
AMD's D3D12 compiler takes an access violation inside
CreateGraphicsPipelineState/CreateComputePipelineStateon RDNA4. On the machine this was found on it killed the wholerun, every time:
This adds a guard, ported from the sibling Belobug/VIctory work (GPL-3.0, credited in the module):
warm-bad.txt, so later runs skip it,make_withno longer usesOnceLock::get_or_init: a parked builder would block every othercaller forever. Pipelines are claimed instead (
claim()/release_claim()), waiters block on acondvar until the pipeline is
Made, andworker_lostreleases a claim with a CAS — no lock theparked worker might hold is taken.
LEONIDA_COMPILER_GUARD(default on) turns the catching off; the bad-key list is still honoured.Tested
32.0.32029.2010.amdxc64.dll+0x861b9f, ~6 s in, no window.crashes and 47 pipelines blacklisted in
warm-bad.txt.cargo test -p leonida-gpu --profile diag --lib pipeline::— 66 passed, 0 failed.cargo clippy -p leonida-gpu --profile diag --all-targets— clean forguard.rs/make.rs(only a pre-existing
unused_mutathost.rs:7633).cargo check --profile diag -p leonida --features diagnostics,mimalloc— clean.Not covered
Direct compiles off the worker path are not guarded and still kill the process:
make::now(BVH builder, off unless
LEONIDA_BVH_BUILDER),make::masked_for, the!workers()fallback,and one-off creations in
compose.rs/host.rs. A crash permanently blacklists that pipelinekey; delete the line to retry.
Disclosure
AI-assisted: yes.
Author: DeepSeek V4.1 Flash.
Reviewer: GPT-6.1 Sol (read-only, independent) — 3 findings; the
make_withclaim race itraised is fixed in this commit (claim/wait, tests at
make.rs:1934+).Provenance: ported from Belobug/VIctory (GPL-3.0), credited in
guard.rs.Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-12-02T20:37:19Z.
Review: COMMENTED
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.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T20:41:23Z.
Review: COMMENTED
Source review on
d59a9d6e. The default-on recovery covers the entirep.make()call (make.rs:1184–1185), includingHostPipeline::newand the subsequent timing bookkeeping (make.rs:210–215).guard.rs:173–174checks the exception kind and accessed address, but does not check whether the fault came from a driver compilation call. An unrelated fault in guarded host code could be attributed to the compiler, andworker_lostthen records the pipeline key permanently. Please narrow or verify the recovery boundary around the intended driver calls before persisting a key. Separately,AddVectoredExceptionHandlercan return null and its result is currently discarded, so the success log can claim recovery is active when registration failed. This was a defensive source review; I did not trigger a fault or run a workload. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T21:44:04Z.
VERIFY-3222 — Windows nativo: la suite pasa, el control muerde, y el guardián se limita a lo que dice
(this PR)b41763227= currentmainmain—merge-treeclean,git merge --no-ffcleanRan
The one failure is this machine's, unchanged all day (
views_are_made_beside_the_heap_and_copied_in, the iGPU artefact ofD3D12CreateDevice(None, ..)that #2995 addresses).Negative control (synthetic): I made the handler's predicate refuse under a test variable (
compiling && code == AV && parameters >= 2 && address < FIRST_TITLE_PAGE), rebuilt and ran →FAILED: only_a_first_page_access_violation_inside_a_compile_is_caught,assertion failed: handles(EXCEPTION_ACCESS_VIOLATION, 2, 0x8, true). The test bites.What I checked because a vectored exception handler is process-wide: the predicate is narrow on purpose — it only handles an
EXCEPTION_ACCESS_VIOLATIONwhile a compile is attached to a slot, with at least two parameters, at an address belowFIRST_TITLE_PAGE— and returnsEXCEPTION_CONTINUE_SEARCHotherwise, so the title's own faults are not swallowed. The tests pin exactly those boundaries (the name says "only a first page access violation"), and the two make-side ones cover the aftermath: a pipeline the compiler crashed on is not built again, and two threads build it once. That last pair is the part that keeps a driver crash from turning into a compile storm, which is what the nightly logs show for other failures.What I could not test
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:00:12Z.
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T22:41:24Z.
RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS on head
d59a9d6e2(merged cleanly viagit merge --no-ffontomain8877be372).Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79)
python -I scripts/check_no_game_data.py-> PASScargo test -p leonida-gpu --lib --locked pipeline:: -- --skip depth_bounds_pipeline_loads_and_filters_draws-> 65 passed, 0 failed, 8 ignored (skipping only the pre-existing Windows 10depth_boundstest tracked in #2855)cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked-> PASSLive In-Game Gate (
-SeriesS -NoFrameGen, defaultLEONIDA_COMPILER_GUARDactive)d59a9d6e2on8877be372)315 s(436.6 s)64(5,451)0/027.8 fps(36.0 ms)22.6/28.4main(8877be372)315 s(441.9 s)63(4,338)0/027.9 fps(35.8 ms)26.1/29.6leonida_gpu::pipeline::guard: the driver's compiler crashing on a worker is caught (LEONIDA_COMPILER_GUARD=0: not)confirmed active in the live log;0compiler crashes and0regressions on this NVIDIA driver (crash-recovery itself is covered by thepipeline::guardunit tests).AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T09:01:28Z.
This pull request has a merge conflict with current
main(d9b618f10), so it can't be run in game or merged as it is. Could you merge the latestmaininto it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T09:21:31Z.
RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS (updated head
3772d3eae)3772d3eaemerged cleanly (git merge --no-ff) ontomain(d9b618f10)python -I scripts/check_no_game_data.py-- PASSpython -I tools/d3d12_switches.py --check d3d12/docs/switches.md-- PASScargo test -p leonida-gpu --lib --locked pipeline:: -- --skip depth_bounds_pipeline_loads_and_filters_draws-- 65 passed, 0 failed, 8 ignored (includingpipeline::guard::tests::only_a_first_page_access_violation_inside_a_compile_is_caught,pipeline::guard::tests::warm_bad_names_a_crashed_pipeline_once_and_reads_back, andpipeline::make::tests::a_pipeline_the_compiler_crashed_on_is_not_built_again)cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked-- PASSLEONIDA_COMPILER_GUARD=1, 315 s in world, 448.0 s total, 65 world samples, max 5,530 draws):leonida_gpu::pipeline::guard: the driver's compiler crashing on a worker is caught (LEONIDA_COMPILER_GUARD=0: not)(0 false trips on NVIDIA)3000-4999draws bucket: 26.6 fps (58 samples)main(d9b618f10) baseline on the same machine/preset: median 27.0 fps (37.1 ms; slowest tenth 20.2, fastest tenth 27.9);3000-4999draws bucket: 27.1 fps (55 samples; within single-run noise)amdxc64.dllcompiler-crash recovery cannot be reproduced on NVIDIA hardware.AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by roanh47 on 2026-12-03T10:00:01Z.
Both points are addressed in
f5b162c3c.(a) The fault boundary. The handler now refuses to attribute a fault to the driver's compiler unless the faulting instruction is outside our own image. At
start()the guard records the allocation our own code lives in (VirtualQueryon its own handler address — no loader lock), and in the handler it asksVirtualQueryfor the allocation of the faultingRip; if that is our own image, it returnsEXCEPTION_CONTINUE_SEARCH, so the fault stays fatal and no pipeline key is written towarm-bad.txt.VirtualQueryis used inside the handler deliberately instead ofGetModuleHandleEx/EnumProcessModules, which take the loader lock a faulting thread could hold. The handler still allocates nothing, takes no lock and touches no file.(b) Registration.
AddVectoredExceptionHandler's return is now checked: on null the guard logs a warning ("no vectored exception handler was registered") and does not print the "crashes are caught" line.Verified in the PR worktree:
cargo check --locked --profile diag -p leonida-gpuexit 0,cargo test -p leonida-gpu --profile diag --lib pipeline::66 passed / 0 failed,cargo clippy -p leonida-gpu --profile diag --all-targetsclean forguard.rs/make.rs.One limit worth stating: this narrows the boundary to "not our image", which is exactly the mis-attribution you described; it does not prove the call is a driver compile call, because proving that from inside a handler would need a loader query. The compiling flag plus the first-page address test plus the not-our-image test are the three cheap conditions available without a lock.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T10:22:02Z.
RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS (updated head
f5b162c3c)f5b162c3cmerged cleanly (git merge --no-ff) ontomain(d9b618f10)python -I scripts/check_no_game_data.py-- PASSpython -I tools/d3d12_switches.py --check d3d12/docs/switches.md-- PASScargo test -p leonida-gpu --lib --locked pipeline:: -- --skip depth_bounds_pipeline_loads_and_filters_draws-- 65 passed, 0 failed, 8 ignored (including thepipeline::guard::tests::*andpipeline::make::tests::a_pipeline_the_compiler_crashed_on_is_not_built_againtests)cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked-- PASSLEONIDA_COMPILER_GUARD=1, 315 s in world, 466.1 s total, 65 world samples, max 5,404 draws):leonida_gpu::pipeline::guard: the driver's compiler crashing on a worker is caught (LEONIDA_COMPILER_GUARD=0: not)(0 false trips on NVIDIA)3000-4999draws bucket: 25.5 fps (60 samples)amdxc64.dllcompiler-crash recovery cannot be reproduced on NVIDIA hardware.AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T14:03:01Z.
This was green and already run in game by a third party, but stuck in conflict on the generated
switches.mdonly (its format changed in #3318). I carried it onto current main in #3333, keeping your two commits as they are, so it can merge. If you update this branch first, #3333 gets closed instead. AI-assisted (Claude Code).