d3d12_xs: shader_xlat mutex poison inconsistency causes crash on compilation thread panic #109
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator#109
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Trwthh on GitHub · 2026-11-22 09:51 UTC · original
Bug
In
crates/compat/d3d12_xs/src/shader_xlat.rs, mutex access is inconsistent:unwrap_or_else(|e| e.into_inner())to recover from a poisoned mutex (correct for resilience).unwrap()on the same kind of global mutexIf a shader compilation thread panics (e.g. from a malformed shader or an OOM), the mutex gets poisoned. The diagnostic/stats codepath then hits the
.unwrap()and crashes the entire emulator with a panic, instead of recovering like the main path does.The same inconsistency appears in
gpu_va.rsline ~29 (recovers) vs other diagnostic paths.Impact
A single bad shader that panics during translation takes down the whole emulator instead of just failing that one shader. This is especially problematic during first-use PSO creation where many shaders compile in rapid succession.
Expected behaviour
All mutex accesses on the same global should use the same poison-recovery pattern (
unwrap_or_else(|e| e.into_inner())), so a panicked compilation thread doesn't cascade into a full crash.@omonkeyz on GitHub · 2026-11-22 14:05 UTC · original
Fix details: published in
aa14bfa(batch commit). Every Mutex lock in crates/compat/d3d12_xs/src/shader_xlat.rs (ORIGIN, CACHE, MESH_ROOT_CACHE, the prewarm queue) now recovers from poisoning with unwrap_or_else(|e| e.into_inner()), like ORIGIN_HASH and LINKS. The test poisoned_shader_globals_recover_instead_of_panicking poisons all three globals and checks that lookups still work. One correction: translation never runs while one of these locks is held (it runs inside OnceLock::get_or_init, under catch_unwind), so a translator panic could not poison them on its own path. The inconsistency was real, though. Thanks for the report.