Skip to content

Tests: avoid poisoning SYNC_GRAPH with an unmapped fake fence in queue_tests (#1978) - #2002

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:d3d12x/fix-parallel-test-race
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:d3d12x/fix-parallel-test-race

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1978.

hle::d3d12x::real::queue_tests::queue_slot_18_before_the_layout_is_known_writes_8_bytes pushed an unmapped sentinel address (0x5EED_0000) into real::FENCES and invoked queue_dispatch(14, this, fence, 1, 0, 0) with a mock signal returning 0 (S_OK). Because hr >= 0, queue_dispatch registered that bogus pointer in fence_x::FENCES (note_queue_signal) and list_x::SYNC_GRAPH.title_fences (note_title_queue_signal), while the test only removed it from real::FENCES.

Under --test-threads=1, hle::d3d12x::list_x::tests::* ran alphabetically before hle::d3d12x::real::queue_tests, hiding the bug. Under parallel cargo test, queue_tests finished first and left 0x5EED_0000 in SYNC_GRAPH.title_fences; as soon as any concurrent list_x test ran would_signal_close_cycle, prune_title_fence(0x5EED_0000, tf) called ID3D12Fence::GetCompletedValue() through the unmapped address and killed the test runner with 0xc0000005 STATUS_ACCESS_VIOLATION.

What is in it

  • Replace the unmapped 0x5EED_0000 sentinel in queue_tests (crates/xcl/src/hle/d3d12x/real.rs) with a valid minimal stack ID3D12Fence COM vtable whose GetCompletedValue returns u64::MAX, so any concurrent prune_title_fence call during the test executes safely without UB.
  • Add #[cfg(test)] cleanup helpers fence_x::forget_fence_for_test (crates/xcl/src/hle/d3d12x/fence_x.rs) and list_x::forget_title_fence_for_test (crates/xcl/src/hle/d3d12x/list_x.rs), invoked from a Drop guard in queue_tests under the respective locks before the stack mock objects go out of scope.
  • Test-only change (#[cfg(test)]); no runtime code paths modified.

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (driver 621.01), AMD Ryzen 5 7500F, 64 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke.
  • Before fix: cargo test -p xcl --lib -- hle::d3d12x::real::queue_tests hle::d3d12x::list_x crashed 3/3 runs with 0xc0000005 STATUS_ACCESS_VIOLATION.
  • After fix (rebased onto ea088a5 at a18f4ab): cargo test -p xcl --lib -- --test-threads=4 hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa hle::d3d12x::real::queue_tests hle::d3d12x::list_x::tests::cross_queue_ passed (5/5), plus 5/5 --test-threads=32 runs on 1d85dd1 and 10/10 runs on 4197910.

Regression run

main:

xcl-smoke v1
commit: 80f4819098e921f2e1ab371144d4832f68ffedd6
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1622 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16539 MB

PR:

xcl-smoke v1
commit: a18f4abdcd96de28414fb2826bab73ef42d9a4b2
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1645 (PresentX 1645)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15200 MB

Not tested

  • Full workspace parallel test run; Intel GPUs; Linux / Wine + vkd3d-proton.

AI use

@upipibi

upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Overlap note: #1523 (mine, opened earlier for #1487, mergeable, CI green) fixes the same crash. It replaces the 0x5EED_0000 integer in queue_slot_18_before_the_layout_is_known_writes_8_bytes with a static fake ID3D12Fence whose GetCompletedValue returns a completed value, so prune_title_fence no longer calls through an unmapped address. JJAutoCompare linked #1978 to it as well.

This PR goes a step further by also removing the test's entries from fence_x::FENCES and SYNC_GRAPH afterwards, which keeps the shared state clean for later tests. If the maintainers prefer that, I'm happy to close #1523 in its favour. Only one of the two should go in.

Separately confirmed here (RTX 3070, Windows 11): the parallel cargo test -p xcl --lib -- cpu_writes q_release queue run died with 0xc0000005 while list_x's cross-queue tests were running. Single-threaded, it passes on both main and another PR's head.


Added 17:50Z: NVIDIA test report for a18f4ab (head as is, base ea088a5), as asked in #1607's NVIDIA list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, after cargo build --workspace:

  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 1236 passed, 0 failed, 46 ignored. The end-to-end title tests pass.
  • main 0829441 on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests).
  • Skipped hle::xaudio2, because its tests fail or hang on this machine on main too. The PR doesn't touch it.
  • SKIPPED lines: 25: 20 no wave64 on this card, 3 f16/f32 forms the per-lane path refuses, 1 no heap windows, and 1 PSO measurement that needs Developer Mode to turn the driver cache off.

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.

@raylitebull

Copy link
Copy Markdown
Member

Review note on 4197910:

  • Diff audited and CI workflow approved (currently running).
  • As noted by @upipibi, #1523 targets the same fake-fence SYNC_GRAPH issue in queue_slot_18_before_the_layout_is_known_writes_8_bytes. Depending on which approach is preferred, #2002 will still need Build and test green plus an AMD verification pass before merge.

@JoaoPauluu

Copy link
Copy Markdown

A run under Wine on Linux, with vkd3d-proton as the host D3D12. The 0xc0000005 from #1978 does not reproduce here, so this cannot confirm the fix. Another abort shows up in the same test pair, on main and on this PR alike.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257. Release lib test binaries, cross-built for x86_64-pc-windows-gnu: 4197910 as it is (based on 6567c5f) and main cbc296a, no uncommitted changes. Each run is one Wine process with --test-threads=4, 10 runs of each, main and this PR alternating.
  • hle::d3d12x::real::queue_tests hle::d3d12x::list_x (the pair from Test suite: parallel cargo test intermittently dies with 0xc0000005 (hle::d3d12x queue_tests × list_x race) #1978):
    • main: 8 of 10 runs ok. 30 passed. In 2, the process died.
    • this PR: 7 of 10 runs ok. 28 passed. In 3, the process died.
    • Every death prints glibc's double free or corruption (!prev) right after vkd3d-proton/DXVK report Found device: NVIDIA GeForce RTX 3060, i.e. while a device is being made. The last test reported before it was list_x::tests::a_mirrored_buffer_binds_its_mirror_without_asking_readable ... ok each time. No 0xc0000005 in any run.
  • hle::d3d12x as a whole:
    • main: 10 of 10 runs end 175 passed; 2 failed; 2 ignored.
    • this PR: 8 of 10 runs end 158 passed; 2 failed; 2 ignored. In 2, the same double free abort came after bind::tests::reset_and_clear_state_track_initial_pso_and_clear_root_args ... ok.
    • The 2 failures are the same on both and in every run: bind::tests::execute_indirect_reads_the_arguments_written_before_it (bind.rs:1086) and device_x::tests::gpu_depth_buffer_created_for_unordered_access_is_placed (device_x.rs:1126). They are unrelated to this PR.

The abort is in the host's C heap (Wine / vkd3d-proton / the Vulkan driver) while devices are made in parallel. It may be a vkd3d-proton or driver problem rather than XCL's, and I have not narrowed it down. It occurs with and without this PR at about the same rate.

Not tested

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@luckyteagirl

Copy link
Copy Markdown
Contributor

AMD Windows verification for PR #2002 at 4197910e7706d722ecbeac7701d345453dc6340a

The maintainer requested an AMD pass on the parallel queue-test crash in #1978. I tested this PR's clean exact head against current main cbc296ab65a2661a61e3e2da109134bcd5319f60 on Windows 11 build 26200, Radeon RX 6800M (driver 30.0.13002.13003), Ryzen 9 5980HX, Rust 1.99.0 MSVC, with XCL_ADAPTER=6800M and 32 test threads.

Each invocation used cargo test -p xcl --lib --locked -j 2 -- --exact --test-threads=32 --show-output <queue_slot_18...> <list_x...>. The first exact test was hle::d3d12x::real::queue_tests::queue_slot_18_before_the_layout_is_known_writes_8_bytes; I paired it separately with:

  1. hle::d3d12x::list_x::tests::cross_queue_cycle_and_same_queue_fifo_do_not_deadlock
  2. hle::d3d12x::list_x::tests::cross_queue_wait64_before_signal_does_not_deadlock_submit_thread
Pair Current main PR #2002 head
Queue slot + cross-queue cycle 5/5 runs exited 0xc0000005 STATUS_ACCESS_VIOLATION before a test total 5/5 runs passed, 2 passed, 0 failed, 0 ignored each
Queue slot + Wait64 before signal 5/5 runs exited 0xc0000005 STATUS_ACCESS_VIOLATION before a test total 5/5 runs passed, 2 passed, 0 failed, 0 ignored each

cargo build --locked --workspace -j 2 also passed on the PR head. These runs exercise the reported test interaction and support the test-only crash fix on AMD. They do not establish that PR #2002 is preferable to the overlapping #1523, nor that the full workspace suite is green.

Not tested: Full library/workspace suite, retail title smoke, Intel/NVIDIA GPUs, or a merge of this older PR base with current main. No game data was used.

AI assistance: OpenAI Codex (GPT-6) ran the comparison and drafted this report.

@throny throny added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 25, 2026
@raylitebull

Copy link
Copy Markdown
Member

Update: #1523 was closed in favour of this PR and #2002 now passes both NVIDIA (RTX 3060 Ti) and AMD (RX 6800M 5/5) verification on 4197910. Recent merges on main created a merge conflict (DIRTY) — @zondy1i, please rebase onto latest main so CI runs and we can merge!

@zondy1i
zondy1i force-pushed the d3d12x/fix-parallel-test-race branch from 4197910 to 1d85dd1 Compare November 25, 2026 10:48
@zondy1i

zondy1i commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@raylitebull Rebased onto latest main (13c2a40) at 1d85dd1 (resolved the adjacent insertion conflict in list_x.rs next to publish_cpu_cycle_break), re-verified 5/5 parallel queue_tests + list_x::cross_queue_ runs (--test-threads=32), and updated the regression smoke block for 1d85dd1.

@raylitebull

Copy link
Copy Markdown
Member

Checked CI run 45598579825 on 1d85dd1: 1154 passed; 1 failed.

  • The single failing test is hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa (crates/xcl/src/hle/d3d12x/device_x.rs:1376), which is a pre-existing failure on origin/main unrelated to #2002; all queue_tests and list_x tests passed.

Remaining before merge: Re-run CI once the main device_x test fix lands (or rebase), plus independent AMD GPU verification on 1d85dd1.

@zondy1i zondy1i closed this Nov 25, 2026
@zondy1i zondy1i reopened this Nov 25, 2026
@zondy1i
zondy1i force-pushed the d3d12x/fix-parallel-test-race branch from 1d85dd1 to a18f4ab Compare November 25, 2026 11:46
@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #2206 solves the same problem (for #1978) in a different way: #1607, group D77. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@zondy1i

zondy1i commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Comparison for #1607 (group D77: #2002 vs #2206):

Only one fix is needed for #1978; #2002 is self-contained and ready to merge.

@thiagocalile

Copy link
Copy Markdown

Independent test report for head a18f4abdcd96de28414fb2826bab73ef42d9a4b2 on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- queue_tests --test-threads=4: 2 passed, 0 failed, 0 ignored (0 skipped).

Not tested: full workspace test suite on this head, NVIDIA/Intel GPUs, or Linux/Wine (test-only PR, no smoke run needed).

AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

AMD RX 7800 XT run of a18f4abdcd96de28414fb2826bab73ef42d9a4b2 (PR head, as-is).

Tested

  • AMD Radeon RX 7800 XT 16 GB (RDNA3, native 64-lane waves), driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 Pro 26200; Rust 1.100.0 MSVC; Windows SDK DXC; debug build
  • The diff only adds #[cfg(test)] helpers and changes the queue_tests module (checked in the diff).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: lib 1175 passed, 1 failed, 26 ignored; every other test binary passed. queue_tests::queue_slot_18_before_the_layout_is_known_writes_8_bytes and newer_layout_maps_dispatch_mesh_to_slot_129_not_128 passed, with no crash from the parallel run.
  • The 1 failure: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 fails (seed 722: res[30] = 0x1, CPU 0x7fffffff); it fails the same way on main in my run, so it is not caused by this PR.
  • main (origin/main 68a284a596bd558b6bd9db6eedda6d6aa178c360) in the same setup: 1218 passed, 2 failed (the fuzz test and lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier).

Not tested

  • scripts/smoke.ps1: not run, as the diff is test-only (a maintainer's test-only label covers it).
  • The full suite ran once, so a rare parallel crash would not necessarily show.
  • NVIDIA, Intel, other AMD generations.

AI use

  • Test report written and run by Claude Code (Claude Sonnet 5.5); no code changed.

@raylitebull
raylitebull merged commit db4ad09 into xcl-dev:main Nov 25, 2026
2 of 3 checks passed
@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

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

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

9 participants