XGameRuntime: wake XAsyncGetStatus waiters before immediate completion callback #1167
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1176"
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-24T12:52:50Z.
XAsyncCompletecalleds.cv.notify_all()aftertaskqueue::submit_now(). When the completion port usesMODE_IMMEDIATE,submit_now()runs the completion callback synchronously on the completing thread, so any callback that synchronises with a thread blocked inXAsyncGetStatus(b, true)deadlocked deterministically because waiters were never woken.This moves
s.cv.notify_all()directly after publishing completion and before submitting the completion callback.What is in it
crates/xcl/src/hle/xgameruntime/xasync.rs: calls.cv.notify_all()beforetaskqueue::submit_now()inXAsyncComplete; add regression testcomplete_wakes_waiters_before_immediate_completion_callback(verified timing out before the fix and passing in ~20 ms after).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): 742 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 complete_wakes_waiters_before_immediate_completion_callback: 1 passed, 0 failed (timed out before the fix)Regression run
main:
PR:
Not tested
AI use
xasync.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-24T13:09:28Z.
Independent verification on current
main384f7f7(branch already contains it — clean).Machine: Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug.
cargo test -p xcl --lib xasync: 16 passed, 0 failed — the waiter-wake ordering change keeps the XAsync suite green.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Imported from ivall/xcl. Originally posted by PedroNunes11 on 2026-11-24T13:16:46Z.
Independent GTA VI long-run regression on the PR head. The XAsync regression test passes, but this change does not resolve the later world-loading stop tracked in #232 on this machine.
Build
978a5de, cherry-picked as local6c64715on currentmain47efa2e+ #549 (d0554f3)XCL_NO_SYSTEM_XGAMERUNTIME=1forces XCL's XTaskQueue/XAsync because the system XGameRuntime path crashes on this installationMachine
Checks
cargo test -p xcl --lib complete_wakes_waiters_before_immediate_completion_callback -- --test-threads=1: 1 passedXCL_NETWORK=0 XCL_ACTIVITY=1 XCL_UMA_MB=4095 XCL_COHERENT_MB=4095;XCL_PSO_WAIT_MSunsetResult
bcpack_refused: empty0xc0000005null write ingame_scarlett_master.exe+0x23cf683, with the same title stack through+0x4e4ba89,+0x2215c35,+0x71b9a20,+0x2215ecaSo the waiter-wake ordering fix behaves correctly in its focused test, but the later GTA VI stop remains independently reproducible. This is intended as scope information, not evidence against the XAsync fix.
AI use: Codex applied the PR in an isolated worktree, ran the tests, extracted the counters from XCL's log/report, and drafted this comment; I observed the game run.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-27T21:26:42Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:59:56Z.
Triage (#1607) – head
978a5deNo other PR makes this change.
Problem: in the reference XAsync implementation (libHttpClient
Source/Task/AsyncLib.cpp),SignalCompletiononly queuesCompletionCallbackwhen a callback is set, andCompletionCallbackruns the callback and thenSignalWait:XAsyncGetStatus(b, true)returns after the completion callback. The test's callback, which waits for theXAsyncGetStatuswaiter to return, would deadlock on the console too. Movings.cv.notify_all()beforesubmit_nowinxasync.rs:XAsyncCompletealso lets a woken waiter free itsXAsyncBlock(a stack block is the usual case after a blocking wait) whilecompletion_cbstill dereferences it on the immediate port.Recommendation: close (bad: inverts the reference wait/callback order and opens a use-after-free of the async block).
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.