GPU: serialize driver pipeline compilation on AMD to prevent amdxc64.dll crash #167

Closed
github-bot wants to merge 2 commits from gh-pr/167/head into gh-pr/167/base
Owner

@⁠a-to-z on GitHub · 2026-11-26 09:15 UTC · original
a-to-z:fix/amd-pipeline-compiler-race → main · +31 −5 · 3 files · 2 commits · closed without merging

Problem

On Windows with AMD graphics cards (such as RDNA 3 / RDNA 4), background pipeline worker threads concurrently invoke Direct3D 12 pipeline creation (CreateGraphicsPipelineState / CreateComputePipelineState).

AMD's shader compiler driver (mdxc64.dll) has an internal race condition in its Boost serialization singleton when multiple threads call into it simultaneously, resulting in a null pointer dereference (
cx == 0) and unhandled exception 0xc0000005:

text amdxc64!boost::serialization::singleton<...>::get_const_instance+0x19a41f 00007ffdc5461b9f 488b7908 mov rdi, qword ptr [rcx+8] ; rcx = 0 (Null-pointer read)

Solution

  1. Added compile_lock() in pipeline/library.rs to serialize driver compilation calls (both in the cold fallback and when library is uninitialized).
  2. Automatically enabled on AMD hardware (VendorId == 0x1002) via crate::indirect::amd.
  3. Supports manual override via VICTORY_DRIVER_COMPILE_LOCK=1 / 0 or VICTORY_LIBRARY_LOCK=1.
  4. Non-AMD GPUs (NVIDIA) continue to compile in parallel with zero mutex overhead.

Testing

  • Verified clean build: cargo build --locked --profile diag -p victory --features diagnostics
  • Verified linter: cargo clippy -p victory-gpu -- -D warnings
  • Eliminates the driver crash during startup on AMD hardware.
**@⁠a-to-z** on GitHub · 2026-11-26 09:15 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/167) `a-to-z:fix/amd-pipeline-compiler-race` → `main` · +31 −5 · 3 files · 2 commits · closed without merging ## Problem On Windows with AMD graphics cards (such as RDNA 3 / RDNA 4), background pipeline worker threads concurrently invoke Direct3D 12 pipeline creation (CreateGraphicsPipelineState / CreateComputePipelineState). AMD's shader compiler driver (mdxc64.dll) has an internal race condition in its Boost serialization singleton when multiple threads call into it simultaneously, resulting in a null pointer dereference ( cx == 0) and unhandled exception 0xc0000005: ``text amdxc64!boost::serialization::singleton<...>::get_const_instance+0x19a41f 00007ffdc5461b9f 488b7908 mov rdi, qword ptr [rcx+8] ; rcx = 0 (Null-pointer read) `` ## Solution 1. Added `compile_lock()` in `pipeline/library.rs` to serialize driver compilation calls (both in the cold fallback and when library is uninitialized). 2. Automatically enabled on AMD hardware (`VendorId == 0x1002`) via `crate::indirect::amd`. 3. Supports manual override via `VICTORY_DRIVER_COMPILE_LOCK=1` / `0` or `VICTORY_LIBRARY_LOCK=1`. 4. Non-AMD GPUs (NVIDIA) continue to compile in parallel with zero mutex overhead. ## Testing - Verified clean build: `cargo build --locked --profile diag -p victory --features diagnostics` - Verified linter: `cargo clippy -p victory-gpu -- -D warnings` - Eliminates the driver crash during startup on AMD hardware.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:21:37 +00:00
github-bot closed this pull request 2026-11-26 11:21:37 +00:00
Author
Owner

@⁠a-to-z on GitHub · 2026-11-26 09:59 UTC · original

Closing: the diagnosis here doesn't hold up.

  • The crash at amdxc64.dll+0x861b9f (null read at 0x8) still happens on this branch with the lock on. It is deterministic, not a race: it happens every run on the first compile of one compute shader (052a2316a03b9ba1, bound at frame 51 during Game Init), seen on an RX 9070 XT (RDNA4, driver 32.0.32029.2010).
  • It goes away with VICTORY_SHADER_OPT=0, i.e. the AMD compiler trips over the shape of the DXIL our clean-up passes produce. Each pass on its own is fine; the combination of DEAD/FOLD/REUSE (7) triggers it. Narrowing down further.
  • Serializing every pipeline library call on all AMD adapters slows pipeline creation for every AMD user (including the 7900 XTX) for no gain.

A follow-up PR will target the actual trigger.

🤖 Generated with Claude Code

**@⁠a-to-z** on GitHub · 2026-11-26 09:59 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/167#issuecomment-7188754497) Closing: the diagnosis here doesn't hold up. - The crash at `amdxc64.dll+0x861b9f` (null read at 0x8) still happens on this branch with the lock on. It is deterministic, not a race: it happens every run on the first compile of one compute shader (`052a2316a03b9ba1`, bound at frame 51 during Game Init), seen on an RX 9070 XT (RDNA4, driver 32.0.32029.2010). - It goes away with `VICTORY_SHADER_OPT=0`, i.e. the AMD compiler trips over the shape of the DXIL our clean-up passes produce. Each pass on its own is fine; the combination of DEAD/FOLD/REUSE (`7`) triggers it. Narrowing down further. - Serializing every pipeline library call on all AMD adapters slows pipeline creation for every AMD user (including the 7900 XTX) for no gain. A follow-up PR will target the actual trigger. 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.