Skip to content

D3D12.X: the GPU wait watchdog starts after its wake pair is set - #1926

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
pvfreis:sync-watchdog-start
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
pvfreis:sync-watchdog-start

Conversation

@pvfreis

@pvfreis pvfreis commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The xcl-sync-watchdog thread, which releases a GPU wait that has not completed after 5 s, could panic as it started. wake_sync_watchdog spawned it inside the OnceLock's initializer, and the thread's first line unwraps that OnceLock. If the thread ran before the initializer returned, it panicked on None and was not started again. The code is from 8a5643f (#795).

Seen once, on main 4178e88 in a retail title run (stderr): thread 'xcl-sync-watchdog' (3856) panicked at crates\xcl\src\hle\d3d12x\list_x.rs:1364:55:, called `Option::unwrap()` on a `None` value. It was 1 of the 12 local title runs without this fix (stderr kept) that bridged GPU waits; with the initializer delayed so that the thread runs first, it happened in both runs (one unit-test run, one title run; below). Royalflamejlh reports a second sighting on Linux (Wine, vkd3d-proton, RTX 4060 Ti): 1 of 144 title runs that logged a bridged wait, the same unwrap. I don't claim that this fixes a stall.

What is in it

  • hle/d3d12x/list_x.rs: the wake pair is set first, then the thread is started by the call that set it (sync_watchdog_pair, which takes the spawn as a closure so that the order can be tested). The thread's body is unchanged. If the spawn fails, nothing retries it, as before.
  • a unit test whose thread starts before the spawn returns: fails on the old order ([false], expected [true]), passes with the fix

Tested

  • RTX 3060 12 GB (driver 617.14), Ryzen 9 5900XT, 32 GB, Windows 11 (26300), Rust 1.100.0, debug
  • cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 976 passed, 0 failed, 45 ignored on 2448457c's tree, run just before it was committed (22 SKIPPED lines: 18 no wave64, 3 wave32 per-lane forms refused, 1 no heap windows)
  • unit tests of main's code with a 300 ms sleep added after the spawn, so that the thread always runs first: the same panic (list_x.rs:1370:55 at 1d027e5); with the fix: none
  • retail title, 140 s, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0, A pressed every 4 s from 20 s, one run per line:
    • main 689f2db + that sleep: the watchdog panics, 3 waits bridged (logged), 0 timed-out releases in the 27 s to the end of the process (17 s of the run, 10 s of drain)
    • this commit + that sleep: no panic, 4 timed-out releases
    • this commit: two runs, no panic, 4 timed-out releases each; a third crashed at 53 s (0xC0000005 read) in title_textures::content_hash (the read that D3D12.X: title texture reads outside the coherent window use the safe copy #751 replaces), before any wait was bridged
    • no device removal, no crash in the others. Presents stopped at 84 to 92 s in every full run, so these runs don't show that the panic or the fix changes the stall

Regression run

main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 3060
title: b6ca0868
seconds: 60
exit: 0x0
frames shown: 1491 (PresentX 1491)
presents per 2 s (last 3): 60 60 52
device removals: 0
crashes: 0
peak commit: 21974 MB

PR:

xcl-smoke v1
commit: 2448457c985eb6f09ba7c7a42c7ea9504590b632
gpu: NVIDIA GeForce RTX 3060
title: b6ca0868
seconds: 60
exit: 0x0
frames shown: 1479 (PresentX 1479)
presents per 2 s (last 3): 60 60 37
device removals: 0
crashes: 0
peak commit: 22378 MB

(the second of two pairs, run main, PR, main, PR; the first: main 1436 frames, peak 21110 MB; PR 1502 frames, 21521 MB; no removal or crash in either)

Not tested

  • AMD; an un-forced panic in the title (it happened once here, on 4178e88, and did not repeat here)
  • other builds ran on this machine during some of the title runs; one run per arm is not a rate
  • the 60 s smoke runs end before the title's first bridged GPU wait (0 in all four), so they don't reach wake_sync_watchdog; the title runs above do
  • the watchdog's other known problem, a wakeup lost between its check and its wait (akimfomin's comment on D3D12.X: bridge Wait64BitValueX to GPU fences with exact cycle breaking #795), is not touched here

Related to #1452 (the watchdog that releases those waits; not a fix for it). If goal:world-load fits, please set it.

Overlaps: #1123, #1045, #1046, #1429, #1580, #1732 and #1323 edit the same function or nearby lines; none fixes this.

AI use

  • Claude Code (Claude Opus 5.5) found it in a log, wrote the fix and the test, ran the tests and the title, and drafted this; Claude Fable 5.2 reviewed it. I have read the diff and the text.

🤖 Generated with Claude Code

wake_sync_watchdog spawned the xcl-sync-watchdog thread inside the
OnceLock's initializer, and the thread's first line unwraps that
OnceLock. If the thread ran before the initializer returned, it panicked
on None.
The initializer has run by then and does not run again, so no timed-out
GPU wait was released on the CPU for the rest of the process.

Seen once on main 4178e88 in a retail title run:
"thread 'xcl-sync-watchdog' (3856) panicked at
crates\xcl\src\hle\d3d12x\list_x.rs:1364:55: called `Option::unwrap()`
on a `None` value".

The pair is set first and the thread is started after it, by the call
that set it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 2448457 (on its base 689f2db).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 966 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: sync_watchdog_pair_is_set_before_the_thread_starts.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 975 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 80f4819 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

A second sighting of the panic 2448457 fixes, on Linux (Wine + vkd3d-proton) + NVIDIA: 1 of the 144 title runs on our machines today (to 17:35) that logged a bridged GPU wait has it, and in that run no wait was released on the CPU afterwards.

The run: RTX 4060 Ti 16 GB (driver 615.71.09), Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b; a local merge of main b8b1f49 with several open pull requests (not a clean main), release, x86_64-pc-windows-gnu, XCL_PSO_WAIT_MS=50, a retail title into its world load; the first-run screens were completed once, no story progress.

  • At 97.6 s the first Wait64BitValueX … bridged to GPU queue.Wait line is logged, and stderr has, between the lines of that moment:
thread 'xcl-sync-watchdog' (2032) panicked at crates/xcl/src/hle/d3d12x/list_x.rs:1374:55:
called `Option::unwrap()` on a `None` value

(the same unwrap as the description's line 1364; the pull requests merged into this tree move it 10 lines down)

  • The log has 8 bridged lines (97.6 to 118.8 s; XCL writes that line for the first 8 only, so 8 or more waits were bridged) and none was released: there is no did not complete within 5000 ms … released on CPU line in the run. The last present was in the 2 s before 120.1 s, and the title's null write at game+0x23cf683 came at 149.5 s. I cannot say that a release would have changed that end.
  • The other 143 runs that bridged a wait have no panic; 50 of them released at least one wait on the CPU, so the thread was alive there. The 144 are 134 under Wine on two cards and 10 on native Windows.
  • The panic is on stderr only. xcl.log has no line of it, which is why it is easy to miss.

Tested

Read

  • list_x.rs:1467 (sync_watchdog_pair): the pair is in the OnceLock before spawn is called, and only the call that made it spawns, so the thread's first get().unwrap() always finds it. A second caller racing the first gets the pair and does not spawn, as before.

Not tested: a title run with the change (the race is rare: 1 in 144 here); the rest of the suite.

AI use: Claude Code (Claude Fable 5.2) read the diff, ran the test, searched the logs of all the runs and wrote this report.

Posted without review by a person: the account owner was away and reads replies later.

@JJAutoCompare

Copy link
Copy Markdown

Empirical verification report for PR #1926 (D3D12.X: the GPU wait watchdog starts after its wake pair is set).

  • PR head tested: 2448457c985eb6f09ba7c7a42c7ea9504590b632
  • origin/main: 5796cc467d80e3dac5d7d231ec34f1b0bebce169
  • Merge check (git merge-tree --write-tree origin/main HEAD): clean (exit 0, tree 530e410553a5500e3a4e81e25d731166ed95873f)
  • PR diff: crates/xcl/src/hle/d3d12x/list_x.rs (+26, -3)

Tested

  • Hardware & environment:
    • GPU: Intel(R) Arc(TM) A770 Graphics (16258 MiB VRAM, driver 32.0.101.9175, 2026-11-04, XCL_ADAPTER=A770)
    • CPU: AMD Ryzen 7 3800X 8-Core Processor (6 cores / 12 logical processors exposed)
    • OS: Microsoft Windows 11 Enterprise Evaluation, Version 10.0.26200 (Build 26200)
    • Rust: rustc 1.100.0 (0ef1bc386 2026-11-09), cargo 1.100.0 (3acc79c0c 2026-11-05), debug (dev / test) profile
    • DXC: dxcompiler.dll 1.9.2609.5 (01b62ad47) (XCL_DXC_DIR -> dxc-1.9.2609\bin\x64)
  • Build:
    • cargo test --workspace --no-run and cargo build --workspace: succeeded (0 errors; 2 pre-existing fetch_update deprecation warnings in real.rs and xgameruntime/mod.rs).
  • PR-targeted tests:
    • cargo test -p xcl --lib sync_watchdog_pair_is_set_before_the_thread_starts -- --show-output: 1 passed, 0 failed, 0 ignored (0.00s).
    • cargo test -p xcl --lib hle::d3d12x::list_x::tests -- --test-threads=4 --show-output: 28 passed, 0 failed, 0 ignored, 0 skipped (0.95s).
  • Full workspace suite:
    • cargo test --workspace -- --test-threads=4 --show-output: exited 101 on xcl --lib (903 passed, 24 failed, 25 ignored), stopping before integration targets.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output (all 20 targets: 19 binaries + doc-tests): 951 passed, 25 failed, 45 ignored (of the 951 passing tests, 15 emitted SKIPPED lines below and are not counted as GPU coverage).
      • xcl --lib: 903 passed, 24 failed, 25 ignored
      • tests\e2e.rs: 2 passed, 1 failed, 0 ignored
      • Remaining 18 targets (bcpack_parity, console_dlls_e2e, console_shaders, disasm_e2e, gpu_compute_e2e, gpu_pso_e2e, heap_probe, low_va, pls_quota, predication_e2e, rpf_e2e, shaders_e2e, sparse_reinit, texture_states, xg_oracle, xcl bin, xcl-testtitle bin, doc-tests): 46 passed, 0 failed, 20 ignored.
  • Failures (25 total, all pre-existing Intel Arc A770 / driver issues outside PR D3D12.X: the GPU wait watchdog starts after its wake pair is set #1926's scope):
    • 20 xcl --lib tests failed in CreateComputePipelineState with 0x80070057: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}, gpu::dxil::ops_tests::{doubles_match_cpu,groupshared_barrier_and_atomics_run}, gpu::dxil::round_tests::{gpu_direct_f32_round_modes_dynamic_and_denormals,gpu_direct_f32_round_modes_static}, gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu, gpu::recomp::tests::{gpu_clamp_and_omod_per_instruction,gpu_f64_class_compare,gpu_f64_compares_with_nan,gpu_f64_literal_high_word,gpu_f64_math_random,gpu_f64_roots,gpu_f64_rounding_and_conversions,gpu_float_compares_random,gpu_frexp_f64_exp_and_mant,gpu_ldexp_f64,gpu_rndne_f64}.
    • 4 xcl --lib shader/driver assertion failures on Arc A770: gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu::recomp::tests::gpu_ps_image_sample_offset_implicit_lod_between_mips, gpu::recomp::tests::gpu_valu_16_and_64_bit, gpu::recomp::tests::gpu_wave64_ps_whole_wave_reductions.
    • 1 tests\e2e.rs failure: test_title_runs_and_game_folder_is_untouched (49/50 xcl_testtitle checks passed, including D3D12.X: console command list memory methods (writes, timestamp, fill, copy, KickoffX, Wait32/64); only D3D12.X: dynamic depth bias via RSSetDepthBiasX (#94) failed on Arc A770).
  • SKIPPED GPU tests (25 SKIPPED lines across 15 tests; not counted as GPU coverage):
    • gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    • gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
    • gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
    • gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    • gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
    • gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (4 subcases): f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); f16 arithmetic, wave64: no wave64; f16 packed, wave64: no wave64
    • gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (7 subcases): f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); f32 arithmetic/compares/conversions/rounding/transcendentals/three-source, wave64: no wave64
    • gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (2 subcases): integer arithmetic, wave64: no wave64; integer carries, wave64: no wave64
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
    • shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): ... (0x887A002D)
    • placed_title_textures_share_vram_and_preserve_pixels: tiled tier < 2
    • test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll
    • heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
    • uploads_start_from_each_subresources_state: no D3D12 debug layer (... 0x887A002D)

Not tested

  • Retail game title / scripts/smoke.ps1 regression run (no game folder available on this test host)
  • AMD RDNA / NVIDIA GPUs, wave64-native GPUs, tiled resources tier 2+, D3D12 debug layer (d3d12SDKLayers.dll / Windows Developer Mode), XCL_HEAP_WINDOWS=1, XCL_SAMPLE_* game-data tests, release profile
  • Reproducing the pre-fix watchdog startup panic on origin/main directly

AI use

  • T3 Code / Antigravity (gemini-4-neon): ran the build and empirical test suite on the hardware listed above and wrote this test report.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 2448457:

  • Initializing SYNC_WATCHDOG_WAKE in sync_watchdog_pair before spawning xcl-sync-watchdog fixes the OnceLock::get().unwrap() startup race cleanly, and sync_watchdog_pair_is_set_before_the_thread_starts directly pins the ordering.
  • Diff audited and CI workflow approved (running); RTX 5070 Ti and Intel Arc A770 passes are already in.

Remaining before merge: Build and test finishing green plus an AMD verification pass on 2448457.

@raylitebull
raylitebull merged commit 025c786 into xcl-dev:main Nov 25, 2026
4 checks passed
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants