Test suite: parallel cargo test intermittently dies with 0xc0000005 (hle::d3d12x queue_tests × list_x race) #1978

Closed
opened 2026-11-26 05:12:30 +00:00 by github-bot · 3 comments
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 00:20 UTC · original

What happened

cargo test -p xcl --lib intermittently kills the whole test process with 0xc0000005 STATUS_ACCESS_VIOLATION when tests run in parallel. Single-threaded (-- --test-threads=1) always passes. This makes every PR verification flaky — roughly 1 in 3 full-suite runs dies.

Minimal reproduction (Windows 11, RTX 3060 Ti, main@1d027e5)

cargo test -p xcl --lib
# or, narrowed down:
cargo test -p xcl --lib hle::d3d12x::real::queue_tests hle::d3d12x::list_x

The narrowed pair crashes 3/3 runs in ~seconds; adding --test-threads=1 passes (28 tests ok). hle::d3d12x as a whole crashes every time; each submodule alone passes.

Bisect notes:

  • hle:: crashes; gpu::, shaders::, vfs, pe::, memory, and every other hle:: submodule pass.
  • Inside hle::d3d12x: only the combination of real::queue_tests (1 test: queue_slot_18_before_the_layout_is_known_writes_8_bytes) with the list_x group reproduces it — queue_tests alone passes, each list_x half alone passes, queue_tests + either half of list_x passed once but the full list_x set crashes consistently.
  • Log tail before the crash shows concurrent ID3D12Device/command-list/queue creation and Wait64BitValueX … bridged to GPU queue.Wait activity — looks like a race in shared D3D12.X state (device/queue/fence or the kernelx GPU-view map) between concurrently running tests, not a logic bug in any single test.

Why it matters

Every contributor running the suite hits this; PR reports keep having to say "flake, passes single-threaded". A #[serial]-style guard around the GPU-touching hle::d3d12x tests, or fixing the shared state, would make the suite trustworthy again.

**@⁠DavidM1911** on GitHub · 2026-11-25 00:20 UTC · [original](https://github.com/xcl-dev/xcl/issues/1978) ### What happened `cargo test -p xcl --lib` intermittently kills the whole test process with `0xc0000005 STATUS_ACCESS_VIOLATION` when tests run in parallel. Single-threaded (`-- --test-threads=1`) always passes. This makes every PR verification flaky — roughly 1 in 3 full-suite runs dies. ### Minimal reproduction (Windows 11, RTX 3060 Ti, `main@1d027e5`) ``` cargo test -p xcl --lib # or, narrowed down: cargo test -p xcl --lib hle::d3d12x::real::queue_tests hle::d3d12x::list_x ``` The narrowed pair crashes 3/3 runs in ~seconds; adding `--test-threads=1` passes (28 tests ok). `hle::d3d12x` as a whole crashes every time; each submodule alone passes. Bisect notes: - `hle::` crashes; `gpu::`, `shaders::`, `vfs`, `pe::`, `memory`, and every other `hle::` submodule pass. - Inside `hle::d3d12x`: only the combination of `real::queue_tests` (1 test: `queue_slot_18_before_the_layout_is_known_writes_8_bytes`) with the `list_x` group reproduces it — `queue_tests` alone passes, each `list_x` half alone passes, `queue_tests` + either half of `list_x` passed once but the full `list_x` set crashes consistently. - Log tail before the crash shows concurrent `ID3D12Device`/command-list/queue creation and `Wait64BitValueX … bridged to GPU queue.Wait` activity — looks like a race in shared D3D12.X state (device/queue/fence or the kernelx GPU-view map) between concurrently running tests, not a logic bug in any single test. ### Why it matters Every contributor running the suite hits this; PR reports keep having to say "flake, passes single-threaded". A `#[serial]`-style guard around the GPU-touching `hle::d3d12x` tests, or fixing the shared state, would make the suite trustworthy again.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:30 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 00:27 UTC · original

Follow-up: likely root cause found.

crates/xcl/src/hle/d3d12x/real.rs keeps the console-layout detection in process-global atomics:

  • QUEUE_SHIFTED (real.rs:5463) — set forever once any queue Signal/Wait-shaped call carries a fence (queue_dispatch, real.rs:5496), and read live by make_layout_split when a command-list vtable is built (real.rs:818).
  • QUEUE_OLDER (real.rs:5467) — same idea for the older layout.

queue_tests::queue_slot_18_before_the_layout_is_known_writes_8_bytes resets both flags and asserts on them, while list_x tests drive real queue Signal/Wait traffic that flips QUEUE_SHIFTED mid-run. Two failure modes:

  1. Test-only: the assertion sees a flag another test set.
  2. Possibly real: make_layout_split reads &QUEUE_SHIFTED while constructing a vtable; if the flag flips between slot mappings, one vtable can end up with mixed old/new slot numbering → a console call lands on the wrong PC function → the 0xc0000005. In production the flip is supposed to happen once, early — but a title calling Signal on one thread while another thread is still creating command lists hits the same window.

So this may not be only a test-isolation problem; the layout detection probably wants to be settled before any command list is built (or the flag read once per vtable, consistently).

**@⁠DavidM1911** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/xcl-dev/xcl/issues/1978#issuecomment-7148533880) Follow-up: likely root cause found. `crates/xcl/src/hle/d3d12x/real.rs` keeps the console-layout detection in process-global atomics: - `QUEUE_SHIFTED` (real.rs:5463) — set forever once any queue `Signal`/`Wait`-shaped call carries a fence (`queue_dispatch`, real.rs:5496), and read live by `make_layout_split` when a command-list vtable is built (real.rs:818). - `QUEUE_OLDER` (real.rs:5467) — same idea for the older layout. `queue_tests::queue_slot_18_before_the_layout_is_known_writes_8_bytes` resets both flags and asserts on them, while `list_x` tests drive real queue Signal/Wait traffic that flips `QUEUE_SHIFTED` mid-run. Two failure modes: 1. Test-only: the assertion sees a flag another test set. 2. **Possibly real**: `make_layout_split` reads `&QUEUE_SHIFTED` while constructing a vtable; if the flag flips between slot mappings, one vtable can end up with mixed old/new slot numbering → a console call lands on the wrong PC function → the 0xc0000005. In production the flip is supposed to happen once, early — but a title calling `Signal` on one thread while another thread is still creating command lists hits the same window. So this may not be only a test-isolation problem; the layout detection probably wants to be settled before any command list is built (or the flag read once per vtable, consistently).
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 00:34 UTC · original

This overlaps the access violation tracked in #1487 and the open test-only PR #1523. Current main@6567c5f still supplies a bare integer as a fence in the reported queue test. The synchronization graph can retain that test value and query it from another test thread. #1523 replaces it with a process-lifetime fake fence whose completion query is valid. I confirmed the PR merges cleanly into that main revision. Queue test · Earlier diagnosis and independent runs

The flag resets still create test interference. One correction to the production hypothesis: make_layout_split captures both targets plus a reference to the flag. The thunk reads that flag at call time, so a flip during vtable construction does not freeze a mix of old and new targets. The next useful comparison here is the same paired test filter at the reported base with and without #1523. This was a source review, without a local reproduction of the crash. Layout dispatch · Assisted by Codex (gpt-6.2-sol).

**@⁠JJAutoCompare** on GitHub · 2026-11-25 00:34 UTC · [original](https://github.com/xcl-dev/xcl/issues/1978#issuecomment-7148650943) This overlaps the access violation tracked in #1487 and the open test-only PR #1523. Current `main@6567c5f` still supplies a bare integer as a fence in the reported queue test. The synchronization graph can retain that test value and query it from another test thread. #1523 replaces it with a process-lifetime fake fence whose completion query is valid. I confirmed the PR merges cleanly into that main revision. [Queue test](https://github.com/xcl-dev/xcl/blob/6567c5ffa38fbc7039b2d6bf520154689cc1f482/crates/xcl/src/hle/d3d12x/real.rs#L6609-L6634) · [Earlier diagnosis and independent runs](https://git.gtahub.st/github/xcl-dev--xcl/issues/1487) The flag resets still create test interference. One correction to the production hypothesis: `make_layout_split` captures both targets plus a reference to the flag. The thunk reads that flag at call time, so a flip during vtable construction does not freeze a mix of old and new targets. The next useful comparison here is the same paired test filter at the reported base with and without #1523. This was a source review, without a local reproduction of the crash. [Layout dispatch](https://github.com/xcl-dev/xcl/blob/6567c5ffa38fbc7039b2d6bf520154689cc1f482/crates/xcl/src/hle/d3d12x/guard.rs#L50-L76) · Assisted by Codex (`gpt-6.2-sol`).
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 00:43 UTC · original

Measured on an RTX 3070 (Windows 11, driver 616.56, debug) with cargo test -p xcl --lib -- cpu_writes q_release queue, which takes in real::queue_tests and the list_x cross-queue tests, at the default thread count:

build runs result
main 80f4819 5 5 × 0xc0000005
#1819 43a0130 (unrelated to this) 5 5 × 0xc0000005
main 80f4819 + #1523 1362129 5 5 × ok, 36 passed

Single-threaded, main passes every time. So the unmapped 0x5EED_0000 fence from queue_slot_18_before_the_layout_is_known_writes_8_bytes is the whole cause here, and either #1523 or #2002 removes it. #2002 also clears the test's entries afterwards. Only one of them should merge.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-25 00:43 UTC · [original](https://github.com/xcl-dev/xcl/issues/1978#issuecomment-7148807377) Measured on an RTX 3070 (Windows 11, driver 616.56, debug) with `cargo test -p xcl --lib -- cpu_writes q_release queue`, which takes in `real::queue_tests` and the `list_x` cross-queue tests, at the default thread count: | build | runs | result | |---|---|---| | `main` `80f4819` | 5 | 5 × `0xc0000005` | | #1819 `43a0130` (unrelated to this) | 5 | 5 × `0xc0000005` | | `main` `80f4819` + #1523 `1362129` | 5 | 5 × ok, 36 passed | Single-threaded, `main` passes every time. So the unmapped `0x5EED_0000` fence from `queue_slot_18_before_the_layout_is_known_writes_8_bytes` is the whole cause here, and either #1523 or #2002 removes it. #2002 also clears the test's entries afterwards. Only one of them should merge. AI-assisted (Claude Code). Synthetic tests only.
This discussion has been locked. Commenting is limited to contributors.
No description provided.