Skip to content

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

Backlog

Description

@DavidM1911

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.

Activity

  1. DavidM1911 commented on Nov 25, 2026

    @DavidM1911
    ContributorAuthor

    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).

  2. JJAutoCompare commented on Nov 25, 2026

    @JJAutoCompare

    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).

  3. upipibi commented on Nov 25, 2026

    @upipibi
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions