gpu: rotate desktop allocator after failed list Close before recovery #1881
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1888"
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 R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-24T20:17:08Z.
Fixes #1876
Root Cause
When
list_close()fails on a command list (Close()returnsE_FAIL), the desktopID3D12CommandAllocator(title.current->real) still has that failed recording attached to it. Inlist_reset(), thestate.list_close_failedrecovery branch calledCreateCommandList(..., title.current->real, ...)directly on the same desktop allocator whilepreviouswas still alive and before the allocator wasReset().d3d12SDKLayers.dllintercepts the invalidRSSetViewportson the compute list before the UMD records it, masking the UMD fault.d3d12SDKLayers.dllwas not installed),nvwgf2umx.dllacceptsCreateCommandListon the tainted allocator and then crashes with0xC0000005(null read at+0x150,nvwgf2umx.dll+0x89014e) on the subsequentreplacement->Close()inlist_close().Summary
src/startup_stubs/d3d12_xs_device.cpp:bool close_failedonDesktopAllocator(set inlist_close()whenClose()fails; cleared inallocator_reset()/ spare reuse afterID3D12CommandAllocator::Reset()succeeds).list_reset(), whentitle.current->close_failedis true andtitle.type == type, rotate to an idle spare desktop allocator (afterReset()) or allocate a fresh one before opening the replacement/reset command list, leaving the tainted allocator untouched untilpreviousis released and the allocator is reset. Wrong-type allocator calls (e.g., DIRECT allocator for a COMPUTE list) still failCreateCommandListwithE_INVALIDARGwithout touching the pool.tests/startup_list_resubmit.cpp:x2w_d3d12_allocator_pool_size(compute_b) == 2after recovery (catches reusing the tainted allocator even on WARP or with the debug layer active).compute_bafter the step 7 submissions complete and verify the pool size stays2(the retired desktop allocator is cleanlyReset()and reused) and a follow-upReset/Close/submit oncompute_bsucceeds cleanly.CMakeLists.txt:startup_list_resubmit_nodebug_warpandstartup_list_resubmit_nodebug_hardware(withoutX2W_D3D12_DEBUG=1) so hosts with the debug layer installed also exercise the direct UMD path.Verification
59c9e234(upstream/main)10.0.26300.9974), MSVC19.44.35230, Windows SDK10.0.26100.0Microsoft Basic Render Driver(1414:008c), driver10.0.26100.9818NVIDIA GeForce RTX 5080(10de:2c02), driver32.0.16.2124Before / After A/B on RTX 5080 (no D3D12 debug layer)
Running
out/build/dev/startup_list_resubmit.exe hardwareandhardware untrackedwithX2W_D3D12_PERMISSIVE=1 X2W_D3D12_LIST_NOOP=1 X2W_D3D12_RENDER=1andX2W_D3D12_DEBUGunset:59c9e234): both crashed with0xC0000005atnvwgf2umx.dll+0x89014e(read of0x150) insidelist_close()->replacement->Close().0(7 recovered Reset: 0x00000000, Close: 0x00000000,desktop allocators behind compute_b: 2,device removed reason: 0x00000000).Commands and Observed Results
startup_list_resubmit_{warp,nodebug_warp,untracked_warp,hardware,nodebug_hardware,untracked_hardware}), debug layer enabled on the non-nodebugruns with0unexpected errors.Observed:
pr23 passed, 4 skipped (spirv_minlod*_warp, local pinned SPIR-V tools not installed), 0 failed (17.51 s);docs_links_check.py: 18 files / 376 links ok;bidi_controls_check.py: 1330 files ok.Scope note: these source-built fixtures verify command-list recovery after a failed
Close()on WARP and RTX 5080; they do not establish full-game startup.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T20:23:07Z.
Built it, ran it, broke one of the three mechanisms
At the PR head, Windows 11 build 26300.9974, WARP 10.0.26100.9818 and the three GPU-less variants:
Three mutations to
src/startup_stubs/d3d12_xs_device.cpp, each rebuilt intod3d12_xs.dll(timestamp verified) and reverted:if (target->close_failed && title.type == type)→if (false)(keep using the tainted allocator)SUCCEEDED(spare->real->Reset())droppedclose_failed = trueSo the decision to stop using a tainted allocator is pinned — which is the root cause in the description — while the two
details around it are not distinguishable with this fixture. Neither looks equivalent on inspection, so I would rather say
what each would need than call them gaps:
Reset()on the spare matters when the spare has been used and is idle. A case wheretitle.poolalready holds aspent allocator that needs resetting before reuse would separate it; if the fixture only ever rotates to a never-used spare,
Reset()is a no-op there.close_failed = trueon a new allocator only changes behaviour on the nextlist_reseton that allocator. One extrareset-then-close cycle after the rotation would make it fail.
Both are cheap additions to
tests/startup_list_resubmit.cppif you want the rotation pinned in the same depth as thedecision.
What the change gets right
The recovery no longer calls
CreateCommandListon an allocator whose failed recording is still attached, and it looks for anidle spare before creating one — which is the right order for a driver that faults on a second recording. The
list_close_failedflag on the wrapper stays for the "replacement needed" case, so the two states (this list failed, thisallocator is tainted) are now separate, which is what the root-cause paragraph describes.
One question
allocator_idle(spare)presumably consultsspare->submitsagainst the fence. If a spare has an untracked submit (theexisting
untrackedflag), is it excluded from rotation? Reading the loop I could not tell whetherallocator_idlereturnsfalse for an untracked allocator or whether that case cannot reach here.
Verdict
Reviewed. The fix addresses the reported crash path and its central decision is pinned by a mutation; the two surrounding
details are not yet distinguishable.
Notes
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T20:32:31Z.
Reproduced the recovery Close crash on main in both hardware submission modes with SDKLayers disabled, then verified the allocator rotation on RTX 4060 Laptop (616.56), Windows 11 26200.9974 and WARP. I added the untracked/no-debug-layer combination to CTest and made the debug-off setting explicit, alongside the recovery note. Debug ctest --preset dev --no-tests=error -R '^startup_list_resubmit_' passed all eight cases, no skips. The production code is unchanged in this follow-up. An independent local diagnostic that held the original list alive also passed, so the measured conclusion is that rotating the allocator fixes the tested failure, without needing to assign a unique internal driver cause.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T21:01:06Z.
Follow-up on the two mutants I reported as not caught before the merge. I re-ran them against the merged fixture (69 commits,
f8f9bd7f), rebuildingd3d12_xs.dlland checking its timestamp each time, then running the three WARP variants:if (spare != title.current && allocator_idle(spare) && SUCCEEDED(spare->real->Reset()))→ drop theReset()target = new DesktopAllocator{created, 0, {}, false, true};(a new allocator bornclose_failed)Step 6 and step 7 in the merged test do cover rotation and the failed-
Closerecovery, so this is not missing coverage of thesituation — it is two details inside it that the assertions cannot separate:
Reset()on the spare. It only matters when the spare has been recorded on before. Step 6's reused allocator is idlebut, as far as I can tell, has never carried a recording, so
Reset()and "noReset()" behave the same there. A step wherethe spare carried a list that was submitted and completed, then is reused, would make the call load-bearing (and the debug
layer would flag a recording on an unreset allocator).
close_failed = trueon a fresh allocator. It only changes the nextlist_reseton that allocator. Step 7 creates anallocator through the rotation path and then finishes, so nothing exercises a second reset on it. One extra
Reset/Closecycle after the recovery would pin it.Both are extensions of the existing steps rather than new scenarios, which is why I am reporting them here instead of opening a
change on top of a fresh merge. If you would rather have them as a patch, say so and I will send the two steps.
Measurement note for anyone repeating this: this test loads
d3d12_xs.dll, so mutating the source and rebuildingstartup_list_resubmitshows "not rebuilt" and proves nothing.