XGameRuntime: prevent timer() from dropping due delayed callbacks during Terminate #1266
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1276"
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-24T14:08:32Z.
Between popping a due
Timedentry from the timer heap and callingsubmit_now(), the delayed item was neither in the timer heap nor counted inQueueState::inflight. A concurrentXTaskQueueTerminatecould observeinflight == [0, 0], invoke its termination callback, and causetimer()'s subsequentlet _ = submit_now(...)to silently drop the callback without running it canceled (leavingXAsyncScheduleblocks permanentlyE_PENDINGand leaking their payloads).This reserves an
inflightslot for the due item while still holding the timer lock (preserving thetimer -> queue.statelock order used bysubmit_delayed), then dispatches viadispatch_due_timed: on successdone_one()releases the temporary slot, and on terminationq.execute()runs the callback directly withcanceled = truesoXTaskQueueTerminatewaits until it completes.What is in it
crates/xcl/src/hle/xgameruntime/taskqueue.rs: reserveinflightunder the timer lock before popping/dispatching a due item viadispatch_due_timed; add unit testdue_delayed_callback_is_canceled_before_terminate_finishes(covering both the deterministic pop-then-terminate window and a 40-iteration live timer-thread race).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): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib due_delayed_callback_is_canceled_before_terminate_finishes: 1 passed, 0 failedRegression run
main:
PR:
Not tested
AI use
taskqueue.rs, wrote the fix and regression test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:10:00Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib xgameruntime: 74 passed, 0 failed.Thanks!
Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T14:14:04Z.
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on
main@930e8b4(baseline 751 passed, 0 failed, 41 ignored on this box):One more than the baseline;
timer()no longer being dropped is exercised and green.Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
Imported from ivall/xcl. Originally posted by CryingLaughing on 2026-11-26T16:50:37Z.
Independent integration check on current
main8b957bec6f82495aec940944c6bf47faa02db590, Windows 11 25H2 build 26200.9974, Core i5-13600K and Rust 1.100.0 x64 MSVC, debug. Both integrations are automatic Git merges with no source overlay.30c30410290e1ddaad7fc3121764976639fa2a1eon current main (treedcd3c64595b7342181b65f682ba445c4c195c415) passed 11 task queue tests and 1 XAsync test.c53eed33ef1625568c739ca854e4eb34db8d1775and #280610dbfac3facf4a1bb93784bcb3eda6203438b134added (treef636fa26df09a112a0aa0a255c42f66c8f3c3b5c), a fresh isolated target passed 13 task queue tests and 1 XAsync test. This included due-callback cancellation before termination, pending delayed callbacks counted byIsEmpty, and explicit dispatch on the caller while the serialized worker was active.Both selections had zero failures, ignored tests, or skips. The runs were CPU-only and did not include retail smoke or scheduling stress beyond the existing fixtures.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:18:36Z.
Triage (#1607) – head
30c3041#315 contains the same timer fix:
inflightis reserved under the timer lock, thendone_oneruns after a successfulsubmit_now, elseexecuteruns canceled. #315 also rewrites the waiter registration, as #1239 does. This PR is the focused, green version of the timer part. The race is still on main:timer()in taskqueue.rs pops the entry, drops the lock, andsubmit_nowsilently drops the item ifXTaskQueueTerminateran in between.One difference from #315: here the canceled callback runs inline on the shared
xcl-taskqueue-timerthread, so a slow title callback delays every other queue's timers; #315 hands it tospawn.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-02T10:17:54Z.
Closing as a duplicate of #315: #1607 group D170, checked by Foniass and Decodere, who both read the diffs and suggest keeping #315. If something here is not in #315, say so and reopen it, or ask and I will.
AI use: Claude Code (Claude Opus 5.5) ran the closing script.
Pull request closed