XGameRuntime: track task queue waiters safely and avoid terminate races #315
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!315
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-315"
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?
@Michael-Glaser on GitHub · 2026-11-23 23:08 UTC · original
Michael-Glaser:fix/taskqueue-waiter-and-terminate→main· +269 −18 · 1 files · 1 commits · openFixes raw-pointer waiter double-free,
MODE_IMMEDIATEself-unregister deadlock, leaked waiters onXTaskQueueTerminate, and atimer()pop-vs-terminate race that dropped canceled delayed callbacks.What is in it
crates/xcl/src/hle/xgameruntime/taskqueue.rs: token-keyedArc<Waiter>map, lockedRegisterWaitForSingleObject, deferred worker-pool unregister on self-unregister, waiter cleanup on terminate,inflighthandoff guard intimer(), and unit tests.Tested
aarch64-apple-darwin, Rust 1.100.0):cargo check --offline --target x86_64-pc-windows-msvc --workspace --tests(0 errors, 0 new warnings).Not tested
cargo testandscripts/smoke.ps1not run yet.AI use
@regiumlepidi on GitHub · 2026-11-23 23:57 UTC · original
A Windows run for this draft, since Not tested says it has not been built or run on Windows yet:
0cdf319merged onto currentmaindb1ddb2(clean merge): builds and passes. One finding: the delayed-callback test does not fail onmainhere.Tested
XCL_ADAPTER=radeon(the Ryzen 7 9800X3D's RDNA2 iGPU, driver 32.0.21030.2001).\scripts\test.ps1(cargo test --workspace -- --test-threads=4), noXCL_SAMPLE_*setmaindb1ddb20cdf319ondb1ddb2delayed_callback_racing_terminate_always_runs_before_termination_callbackcopied unchanged intomain'staskqueue.rs(it uses only existing exports): passed 60 of 60 runs (40 iterations each). So on this machine it does not reproduce the drop / run-after-termination race the timer change fixes, and would not catch it coming back. A wider window between the timer popping the item andXTaskQueueTerminate(for example a delay long enough that the item is popped while terminate is running, rather thaniter % 2ms) might make it fail onmain.waiter_unregister_handles_duplicates_bogus_tokens_and_self_unregistercannot be run againstmain: it uses the newwaiters()map, andmaintakes the token as aBox<Waiter>pointer, so the bogus-token call would dereference0xDEADBEEFCAFEBABE.Not tested
scripts/smoke.ps1on a real title (I have none).AI use: Claude Code with Claude Opus 5.5 ran the build and tests and wrote this comment; the numbers come from those runs.
@Michael-Glaser on GitHub · 2026-11-24 00:17 UTC · original
Thanks @regiumlepidi! Rebased onto main (
a6f5f7a, commit 04b8042) and replaced the timing loop with a deterministic dispatch_due_timed pop-vs-terminate test that holds Terminate right between pop() and submit_now() so it reliably reproduces the dropped callback without the fix.@WebIdentity1 on GitHub · 2026-11-24 02:53 UTC · original · edited 2026-11-24 03:01 UTC
Updated-head Windows validation:
04b8042fbbe99f771e2a9b5f24ba9bb286f3f80aapplied to maindd2ae9a70af5eb5aad60f02d86e386b72abe1e95, clean integration tree85a5bd5a89b75b4f77b6058d28f35b10fe0ba7dd. The deterministic timer test now catches the old behavior.Tested
cargo test --locked -p xcl --lib hle::xgameruntime::taskqueue:: -- --test-threads=1 --show-output: 12 passed, 0 failed, 0 ignored, no skips. This includes both updated waiter and timer regressions.dispatch_due_timedwith pop → release timer lock →after_pop()→submit_now, preserving the deterministic fixture.cargo test --locked -p xcl --lib delayed_callback_racing_terminate_always_runs_before_termination_callback -- --test-threads=1 --show-output: 0 passed, 1 failed, 0 ignored. Observed zero callbacks instead of one. No timeout. Restored the PR helper before the full run.cargo build --locked --workspacesucceeded.cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output: 691 passed, 1 failed, 41 ignored. Onlygpu_clamp_and_omod_per_instructionfailed, previously reproduced on main. Presentation fixtures ran in desktop session1;XCL_ADAPTER=3090, while some fixtures select AMD directly.gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no native wave64 on NVIDIA),test_title_draws_with_a_root_signature_under_the_debug_layeranduploads_start_from_each_subresources_state(debug layer unavailable).XCL_SAMPLE_*variables unset.8d0bbc8, retained async queue):cargo test --locked -p xcl --lib hle::xgameruntime:: -- --test-threads=1 --show-output78/0/0, no skips. The full workspace result above does not include #641.Not tested
Retail smoke, release builds, Wine, installed PC XGameRuntime, or full-workspace execution with #641. The restored-old-behavior control covers the timer handoff; it does not test the old unsafe waiter-token implementation.
AI use
Codex (GPT-6) inspected the code, prepared the negative control, ran the native tests and wrote this report. No competing implementation.
@Michael-Glaser on GitHub · 2026-11-24 13:53 UTC · original
Thanks @WebIdentity1 for validating
04b8042and the deterministic negative control! Rebased cleanly ontomain(47efa2e, commit3a684ef); cross-checked againstx86_64-pc-windows-msvc(--workspace --tests).@Toons29 on GitHub · 2026-11-25 02:54 UTC · original
Regression run of
3a684ef2on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@DavidM1911 on GitHub · 2026-11-25 14:29 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
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.