Repository navigation
Conversation
…ing Terminate Between popping a due Timed entry from the timer heap and calling submit_now(), the item was neither in the timer heap nor counted in QueueState::inflight. A concurrent XTaskQueueTerminate could see inflight == [0, 0], fire its termination callback, and cause timer()'s subsequent `let _ = submit_now(...)` to silently discard the callback without running it canceled (leaving XAsyncSchedule blocks permanently E_PENDING). Increment `inflight` for the due item while still holding the timer lock (preserving the timer -> queue.state lock order used by submit_delayed), then dispatch via dispatch_due_timed: on success release the temporary inflight count with done_one(), and on termination run q.execute() directly with canceled = true so Terminate waits until the canceled callback completes. Assisted-by: OpenCode (Gemini 4 Neon)
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
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 One more than the baseline; 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. |
# Conflicts: # crates/xcl/src/hle/xgameruntime/taskqueue.rs
…#1681 + xcl-dev#1276) Windows hle/xgameruntime/taskqueue.rs hunks verbatim (cfg(windows)-only, 0 tests run on Linux): xcl-dev#1681 timer-heap leg in XTaskQueueIsEmpty (lock order timer -> items -> state) + test; xcl-dev#1276 inflight reserve under the timer lock + dispatch_due_timed with canceled-execute fallback + test. Fidelity: diff vs pr1681head/pr1276head shows only the other PR's hunks. Linux live twin hle/xtaskqueue_linux.rs gets both semantics (win64 ABI) + 2 Linux-shaped tests. Failing-first shown in an isolated pre-fix worktree (since removed): IsEmpty test FAILED at runtime, due-delayed test failed to compile on missing dispatch_due_timed; both green post. Gates: both cargo checks 0 errors; lib 650/0/1 t=4 (+2); diff --check clean; title fresh-root FAIL set byte-identical pre/post (13: 12 D3D12.X GPU-only + files:delete os-error-2, the latter also failing on pristine HEAD - pre-existing drift, no regress); retail fresh-root SIGSEGV +0x2237320 fault 0x0 exit 139 stubs 20 xgr 3 apis - HOLDS.
, verbatim Windows + Linux twin) Live pr805head=e88ee4d1 still OPEN (merge-base false); Windows hle/xgameruntime/taskqueue.rs hunks hand-applied byte-identical (cherry-pick -n conflicted at the shared test-site tail: steps-49/50 tests moved the append anchor; production + test hunks verified identical to the head by direct diff, only line numbers drift). Fidelity: git diff pr805head shows only steps-49/50 drift (xcl-dev#1276/xcl-dev#1681 timer, xcl-dev#1154 terminate); pool block + mpsc test import + new test byte-identical. Production: fixed clamp(2,8) mpsc pool -> Pool{Mutex<PoolState>,Condvar, base} + MAX_WORKERS=256 + IDLE_EXIT 30s + worker loop + spawn wake-idle-else-grow with rollback + notify on spawn failure. Linux live twin hle/xtaskqueue_linux.rs mirrors the production hunks (ABI-neutral pool; win64 ABI untouched) + 1 Linux-shaped twin test (16 blockers + releaser through wait=true Terminate, extern win64). Failing-first: twin test FAILED pre-fix (7 vs 16, releaser starved on the fixed 8-worker pool), green post-fix. Gates: both cargo checks 0 errors; lib 652/0/1 t=4 (+1); diff --check clean; lock audit clean (named g/ng guards, explicit drop before job). Title fresh-root 12 unique FAILs all D3D12.X GPU-only 0 non-GPU (harness FAILs by design, M2 baseline). Retail fresh-root SIGSEGV game_scarlett_master.exe +0x2237320 fault 0x0 unmapped exit 139 stubs 20 xgr exactly XAsync/XNetworking/XUser unimplemented [] - HOLDS, M1-RE TERMINAL.
…l-dev#1239 + xcl-dev#315, verbatim Windows + Linux twin) Windows hle/xgameruntime/taskqueue.rs: xcl-dev#315 waiter form (superset of xcl-dev#1239): immutable Arc<Waiter> (wait Mutex + stopped + callback_arc), monotonic-u64 token map, IN_WAITER thread-local + guard, non-blocking self-unregister offload to pool, post-insert terminated race, Terminate waiter cleanup. xcl-dev#1239 + xcl-dev#315 waiter tests verbatim. xcl-dev#315 timer hunk skipped: landed xcl-dev#1276 already covers the due-timer race (different dispatch_due_timed shape); its timer test superseded by the landed deterministic + 40-iter tests. Linux hle/xtaskqueue_linux.rs twin: helper-thread-per-waiter on kernelx WaitForSingleObject (5ms poll), same token map / guard / cleanup, win64 ABI, 4 twin tests (fires-once, dup/bogus, self-unregister, terminate). Failing-first: grafted twin probe onto HEAD worktree E0425 (no waiters()); twin 11/11 green.
|
Independent integration check on current
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. |
|
#315 contains the same timer fix: AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
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.