XGameRuntime: prevent timer() from dropping due delayed callbacks during Terminate #1276
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1276
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@b3IKK on GitHub · 2026-11-24 14:08 UTC · original
b3IKK:xgameruntime/timer-terminate-no-drop→main· +100 −1 · 1 files · 1 commits · openBetween 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.@DavidM1911 on GitHub · 2026-11-24 14:10 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib xgameruntime: 74 passed, 0 failed.Thanks!
@dcastell1 on GitHub · 2026-11-24 14:14 UTC · original
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.