XGameRuntime: unregistering an association callback cancels it #1743
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1753"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T20:16:18Z.
Addresses
XCL-BT-041from #1488.XUserUnregisterForDeviceAssociationChangeddropped the registration, ignoredwait, and left the callbacks it had already handed to the title's queue untouched: one queued behind the call still ran the title's callback with the title's context, which the title is free to free once the call returns (wait = trueis the documented way to know it is safe). A running callback was not waited for either.This tracks each queued callback's state (
Queued/Running/Done): the unregister marks a queued one done — the queue's later call then skips the title's callback and just releases the record — and withwaitit waits for a running one to finish before returning.What is in it
crates/xcl/src/hle/xgameruntime/mod.rs:AssociationCallcarries its token and aQueued/Running/Donestate with a condvar;ASSOCIATION_CALLSholds the live records;association_callskips a call that was unregistered (or whose queue was terminated) and signals when it is done;XUserUnregisterForDeviceAssociationChanged(token, wait)cancels queued calls and waits for running ones;notify_associationpasses the token.an_unregistered_association_callback_does_not_run(manual queue: queued, unregistered, dispatched → not called; a later registration still runs). Fails onmainwithleft: 1, right: 0(the callback was unregistered: its context may be gone).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 960 passed, 0 failed, 43 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cargo test -p xcl --lib xgameruntime: 74 passed, 0 failedRegression run
main (
c4d37be, clean tree, no local changes):PR (
d7ced4d, clean tree, no local changes):Not tested
wait = falseis the one for that)AI use
XCL-BT-041against the queue andxasynccallback paths, wrote the state machine and the test (and confirmed it fails without the fix), rebased ontoc4d37be, ran the test suite andscripts/smoke.ps1regression runs with #677's title hashing, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T21:18:24Z.
Full-suite run, since this PR has no test report yet. Tested exact head
8cd4248(on its basec160d86).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 858 passed, 0 failed, 42 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.an_unregistered_association_callback_does_not_run.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 859 passed, 0 failed, 42 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipon NVIDIA. Both fail on main7f7e768too, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns their skips into failures.heap_window_out_of_memory_falls_back_to_the_switch_formskips whenXCL_HEAP_WINDOWSis unset (#1651), andshaders::tests::pso_measurement_compiles_an_exact_synthetic_recordskips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not setXCL_REQUIRE_GPU, so there both just print SKIPPED.Not tested
AI use
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T21:32:43Z.
Rebased onto
c4d37beand re-ran both with the current scripts/smoke.ps1 (#677's hashed itle: line): 960 passed, 0 failed, 43 ignored.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T23:04:38Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:37:49Z.
Two contributors checked independently and found that #1418 #1583 solves the same problem (for #1389) in a different way: #1607, group D58. 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.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T03:32:21Z.
PR #1753 compatibility verification
Tested XGameRuntime association callback cancellation at
d7ced4d6ad1913c0b28280dc287755eac9e3b41c.Tested
DoublePrecisionFloatShaderOps=0). DXC/DXIL 1.9.2609.5. D3D12 SDK layers absent.rustc 1.100.0 (0ef1bc386 2026-11-09). Unoptimized dev and test profiles with debug info disabled.cargo build --workspaceandcargo test --workspace --no-runsucceeded outside the GPU lock.cargo test -p xcl xgameruntime -- --nocapturereported 74 unit tests passed, 0 failed, 0 ignored. The matching libHttpClient integration test also reported a pass after returning early becauseXCL_SAMPLE_DLLSwas unset. Two unit tests returned early for missing systemxgameruntime.dlland audio endpoint.an_unregistered_association_callback_does_not_runpassed in both runs. Dispatching the manual completion queue after unregistering withwait=trueleft the callback count at zero. A separate registration received one callback when dispatched.cargo test --workspace --no-fail-fast -- --test-threads=4ran once under the shared Arc lock. Cargo exited 101. Summed across 20 result lines inpr1753-suite.log: 941 passed, 19 failed, 43 ignored. The log contains 22SKIPPEDlines. Raw pass totals include tests that returned early.Failures and skips
0x80070057) and four result mismatches involving FMA, mip sampling, f16 lane preservation, and a pixel-shader wave reduction. The built-in test title had one failure:RSSetDepthBiasXleft the test pixel blue where green was expected.Not tested
Retail-title smoke runs, a
mainbaseline, other GPUs, and game-data cases requiring the unsetXCL_SAMPLE_*inputs. The callback regression test exercises queued cancellation. Waiting for a callback already in flight was untested.AI use
T3 Code / Codex (
gpt-6.2-sol,reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity,gemini-4-neon) verified counts againstpr1753-suite.logand published this report.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T10:13:55Z.
Independent Windows run on d7ced4d. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC.
cargo build --workspace --offline --locked -j 4passed.cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4finished with 960 passed, 0 failed, 43 ignored, with 23 runtime skips in Cargo’s pass count. The queued-callback regression passed.I also tested a callback that had already started on another thread. With
wait=false, unregister returned while the callback was still running. Withwait=true, unregister returned after the callback finished. The callback context stayed alive until both threads joined. The scratch fixture passed 1 of 1 withcargo test --offline --locked -j 4 -p xcl --lib local_unregister_waits_only_when_requested_for_running_callback -- --nocapture --test-threads=1, then passed in 20 of 20 fresh test processes. This covers unregister from a separate thread on a synthetic manual queue.AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:38:56Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T16:06:21Z.
Code review location:
crates/xcl/src/hle/xgameruntime/mod.rs; line 976If the title unregisters this token from inside its own callback with
wait = true, this waits forDone, but the only code that setsDonefor a running callback executes after the callback returns. That self-unregister therefore deadlocks the queue thread. Could the running state record its thread (or otherwise detect reentrant unregister) and skip waiting for the current callback, with a regression test?Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T16:06:21Z.
Review: COMMENTED
AI-assisted review (OpenAI GPT-6). I inspected the unregister state transition and callback completion path; I did not run tests.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-26T17:20:56Z.
NVIDIA and AMD full-suite run, to go with the reports above by JJAutoCompare, thehollowedone, since none of them covers AMD. Tested exact head
d7ced4d6(on its basec4d37be).Tested
cargo build --workspace, thenXCL_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::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 955 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.an_unregistered_association_callback_does_not_run.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 960 passed, 0 failed, 43 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #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 #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 #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 #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 #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main8b957bectoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T13:39:00Z.
merge-check claim
head:
d7ced4d6adImported from ivall/xcl. Originally posted by throny on 2026-11-28T13:55:08Z.
merge-check
base:
e13d6250head:
d7ced4d6admerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2131 passed, 10 failed, 48 ignored (26 SKIPPED lines). The 10 failures are the ones main itself has at
e13d6250on this GPU (#3093: the nine since #2959 and, since today, gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions), the same set with and without this PR; base alone: 2130 passed, 10 failed, 48 ignored.review: no deadlock between the locks of the module (the call table is always taken before the state lock; the unregister drops the table before it waits). Two things worth fixing, not blocking: a title that unregisters its own callback with wait=true from inside that callback waits for ever, because its call only becomes done after it returns (a check against the thread of the callback avoids it; whether the console forbids this I did not verify); and the new test does not take the lock the neighbouring async test takes, while asserting that the second token is the first plus one, which can race with the registration in that test. The triage names #1418 as an overlapping fix for the same issue.
performance: none (one small allocation and a lock per sign-in).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by relativespace2K on 2026-11-30T01:26:22Z.
merge-check
base:
53e85fb1head:
d7ced4d6admerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2789 passed, 6 failed, 49 ignored; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in
--test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base53e85fb1alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR, and the PR's own test passed (hle::xgameruntime::tests::an_unregistered_association_callback_does_not_run). 13 SKIPPED lines, all environmental: no D3D12 debug layer / d3d12SDKLayers.dll, no heap windows, no GPU_UPLOAD, per-lane f16/f32 forms refused.review: no blocking finding; 134 lines in
crates/xcl/src/hle/xgameruntime/mod.rs, every hunk read. The cancel/wait bookkeeping holds up:ASSOCIATION_CALLSis the only way to reach a callback already handed to a queue, the rawArckeeps the record alive until the queue calls it, a queued call is markedDoneand skipped by that later call, andwaitblocks only on the running ones. Lock order is one-way (unregister: registry then state; callback: state, never held while taking the registry), so no inversion. Notes, not blocking: (a) the test covers the queued-cancel path but notwait = trueagainst a callback that is already running, which is the other half of the change; (b) a call left in a queue that is closed without dispatching, and never unregistered, keeps its entry inASSOCIATION_CALLS(the oldBoxleaked the same way, now a little larger per call). Duplicates: this PR is in group D58 on #1607 with the open #1418 (per-entry association state) and the closed #1231/#1583; the group text describes #1583's per-entry condvar registry, which is what this PR implements, so I read it as the group's surviving approach rather than a copy of an open PR, but #1418 is still open and only one of them should merge.performance: negligible: two mutexes and a condvar on register, sign-in and unregister only, nothing per frame, per draw or per callback dispatch; the registry holds only calls a queue has not finished.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash.