XAsync: canceling a call that already completed leaves it alone, as documented #1098
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1098
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1098/head"
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?
@BastienRodz on GitHub · 2026-11-24 15:43 UTC · original
BastienRodz:hle/cancel-after-completion→main· +66 −1 · 1 files · 1 commits · merged 2026-11-25 00:12 UTCWhat's wrong
Microsoft's
XAsyncCancelreference states:In
crates/victory-hle/src/modules/xasync.rs,XAsyncCancelunconditionally dispatchesOP_CANCELwhenever the call is still registered:A call that completed successfully with a nonempty result stays in
CALLSuntil the title consumes the payload viaXAsyncGetResult.Sequence:
S_OKand a 1-byte result.XAsyncGetStatus(block, false)returnsS_OK.XAsyncCancel(block)is called beforeXAsyncGetResult.OP_CANCEL; status staysS_OK;XAsyncGetResultreturns the byte.OP_CANCELonce (thenXAsyncCompletereturns early becausecall.doneis alreadytrue, so the status and result survive).What the fix does
In
XAsyncCancel, checks*lock(&call.done)before invoking the provider and returns immediately if the call has already completed. The lock guard is dropped at the end of theifcondition beforecall.provider(...)runs, avoiding deadlock if a provider callsXAsyncCompleteduringOP_CANCEL. UpdatesXAsyncCancel's doc comment accordingly.How it behaves after the fix
Calling
XAsyncCancelon a call that has already completed returns without sendingOP_CANCELto the provider, leaving the status (S_OK) and unread result intact forXAsyncGetResult. In-flight calls still receiveOP_CANCELand complete withE_ABORT.Tests
modules::xasync::tests::canceling_a_completed_call_leaves_it_aloneincrates/victory-hle/src/modules/xasync.rs: completes a call withS_OKand a 1-byte result (0x5a), callsXAsyncCancel, checks that the provider'sOP_CANCELcount stays0, checks thatXAsyncGetStatusstaysS_OK, and verifiesXAsyncGetResultstill returns0x5a(used == 1).mainbefore the fix:cargo xwin,x86_64-pc-windows-msvc):cargo xwin test -p victory-hle --target x86_64-pc-windows-msvc modules::xasync::tests: 8 passed, 0 failed.cargo xwin test -p victory-hle --target x86_64-pc-windows-msvc: 92 passed, 3 failed (the 3 known Wine baseline failures:modules::lifecycle::tests::hooked_windows_still_reach_the_title_procedure,modules::lifecycle::tests::the_keyboard_menu_never_reaches_the_title,modules::net::tests::only_loopback_is_reachable).cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: pass.cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings: pass.cargo xtask policy: pass (asset policy: 154 files ok).windows-latestwith the upstream CI's commands (clippy-D warningswith and without--all-features, thencargo test --workspace --locked), everything passes;victory-hle95 passed, 0 failed: https://github.com/BastienRodz/VIctory/actions/runs/45428269761Not tested: a title's teardown path.
Related: #122, #236 (both touch XAsyncCancel's completion line; this change sits before it).
No game data used. AI-assisted: found with GPT-6.2 Astra, implemented with Gemini 4 Neon, reviewed and verified with Claude Code.
🤖 Generated with Claude Code
@Aniseto on GitHub · 2026-11-24 16:13 UTC · original
Ran the new test and the whole
xasyncmodule at44ce067:Environment: Windows 11 Pro build 26200 x64, Intel Core i5-12400F, 64 GB RAM, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only) driver 32.0.16.2124, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.modules::xasync::tests::canceling_a_completed_call_leaves_it_alonepasses and the rest of the module is unaffected. It is a unit-level test, so the adapter is not the variable; the datapoint is the pinned 1.98.1 toolchain. No test report on this PR yet.Not tested: the title's own cancellation timing (no game data here), RDNA2/RDNA4 and Intel GPUs, release build.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; no game data was used.
@Zipettte on GitHub · 2026-11-24 16:29 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
44ce067:cargo test -p victory-hlepasses, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).