Repository navigation
D3D12.X: catch panics in async PSO builds so waiters and workers do not stall - #2053
RandomGithub12309 wants to merge 1 commit into
Conversation
…ot stall `dxc::pool()` already wraps HLSL compilation in `catch_unwind`, but the async pipeline jobs in `pso_async` ran the shader translator and D3D12 PSO creation without panic recovery or RAII cleanup: - On an `xcl-pso-*` or `xcl-pso-pre-*` worker, a panic terminated the worker thread permanently and skipped `complete(p, 0)`, leaving `*p.done` false forever so waiting `resolve_wait` callers deadlocked and `p.demand.preload_thread` / `BUILDING` were left stale. - On an inline lazy bind in `resolve_wait_for`, a panic skipped `complete(&p, 0)` (deadlocking concurrent waiters) and unwound toward the `extern "system"` `SetPipelineState` / `ClearState` COM hooks. Catch panics in a shared `run_job` helper (logging the payload and falling back to `0` so `complete` increments `FAILED` and wakes waiters with the stand-in), and restore `BUILDING`, `preload_thread`, and preload worker thread priority via a `BuildGuard` before calling `complete`. Assisted-by: Antigravity (Gemini 4 Neon)
|
Code review on
|
PR #2053 compatibility verificationTested Environment
Tested
The log contains 27 lines beginning with FailuresAll 27 library failures are unrelated to the changed async PSO path by code inspection. The GPU shader tests use the test runner's direct D3D12 calls. No baseline run was performed. 22 tests received
Five shader output mismatches
One integration failure
Not testedNo retail Xbox title or retail shader-pack input, no D3D12 debug-layer validation, no AI useT3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
# Conflicts: # crates/xcl/src/hle/d3d12x/pso_async.rs
|
Linux (Wine + vkd3d-proton) + NVIDIA test of Setup: Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, RTX 4070 12 GB (driver 615.71.09). Release, cross-compiled to Tested
Not tested: a build that panics in a title run; Windows; AMD and Intel. AI use: Claude Code read the diff, built the trees, ran the title and the tests, and wrote this comment: Claude Fable 5.2 for the earlier part (the tests and the two runs without the change at least), Claude Opus 5.5 for the writing; the session changed model during the work. Posted without review by a person: the account owner was away and reads replies later. |
dxc::pool()wraps HLSL compilation instd::panic::catch_unwindso a panicking compile cannot kill a DXC worker or hang its caller, butpso_asyncran each pipeline's full shader translation and D3D12 PSO build closure without panic recovery or RAII cleanup:xcl-pso-*orxcl-pso-pre-*worker killed the worker thread permanently and skippedcomplete(p, 0), leaving*p.done == falseforever so waitingresolve_waitcalls deadlocked onp.cv.wait(withHELDelevated indefinitely) andBUILDING/p.demand.preload_threadremained stale.resolve_wait_forskippedcomplete(&p, 0)(deadlocking concurrent waiters) and unwound toward theextern "system"SetPipelineState/ClearStateCOM vtable hooks.What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs:run_job()wrapping eachJobinstd::panic::catch_unwind(AssertUnwindSafe(job)), logging the panic payload viaxlog_error!and returning0socomplete()incrementsFAILED, marks*p.done = true, and wakes waiting binds with the stand-in pipeline.BuildGuardinbuild()that clearsp.demand.preload_thread, restoresTHREAD_PRIORITY_LOWESTwhen boosted, and clearsBUILDINGbeforecomplete()notifies waiters.build()) and inline bind builds (resolve_wait_for()) throughrun_job().pso_async::used_tests(all three fail before the fix and pass after):a_panicking_worker_build_wakes_waiters_and_keeps_workers_alivea_panicking_preload_build_restores_state_and_keeps_preloaders_alivea_panicking_inline_bind_build_does_not_unwind_or_hang_waitersTested
Hardware: Windows 11 (Build 26300), Intel Core Ultra 7 255HX, NVIDIA GeForce RTX 5050 Laptop GPU (wave32-only, driver 32.0.16.2114),
rustc 1.100.0 (0ef1bc386 2026-11-09)stable-x86_64-pc-windows-msvc, Windows SDK DXC1.8.2502.11.cargo test -p xcl --lib hle::d3d12x::pso_async::used_tests::a_panicking -- --test-threads=1→0 passed; 3 failed(worker threads died and waiters timed out; inline builder unwound).ea16145):cargo test -p xcl --lib hle::d3d12x::pso_async -- --test-threads=4and-- --test-threads=1→9 passed; 0 failed; 0 ignored.cargo build --workspace→ succeeded.cargo test --workspace -- --test-threads=4 --skip fuzz_validate_and_gpu:xcllib:1083 passed; 0 failed; 26 ignored; 4 filtered out(gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}, pre-existing RTX 500x8007000Efailure tracked by DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905);24 SKIPPEDlines printed inside passing tests (20 wave64 / no-wave64 sub-cases, 3 wave32 per-lane refused sub-cases, 1pso_measurement_compiles_an_exact_synthetic_recorddue to Developer Mode being off).49 passed; 0 failed; 20 ignored(1 SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsingpu_compute_e2e).1132 passed; 0 failed; 46 ignored; 4 filtered out(25 SKIPPEDnotices).Regression run
Baseline (
upstream/main):PR head (
ea16145):Not tested
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}(DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905), andpso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode not enabled on this host).AI use
Antigravity (Gemini 4 Neon) identified the missing panic recovery and RAII cleanup in
pso_async.rs, wrote the fix and regression tests, ran the test suite and smoke runs, and drafted this PR description.