XAsync: a new block where a result was left behind begins a call #247
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!247
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/247/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?
@Maraco91 on GitHub · 2026-11-24 01:46 UTC · original
Maraco91:xasync/new-block-at-abandoned-address→main· +77 −1 · 1 files · 1 commits · merged 2026-11-25 00:10 UTCWhat
After a title leaves one result unfetched, every later async call whose block lands on that address fails with
E_INVALIDARG.Calls are filed in
CALLSby their block's address. A call that fails, or succeeds with nothing to fetch, is removed when it completes; one that succeeds with a result stays filed untilXAsyncGetResulttakes it.XAsyncBeginrefuses a block if any call is filed under its address:A title that does not fetch a result (it only wanted the status, it gave up, its fetch failed with too small a buffer) and then frees the block leaves that entry behind for good. Blocks are small heap objects of one size, so the allocator hands the same address out again soon, and from then on a new, zeroed block there cannot begin any call: not the title's own providers', and not ours (
finished_with/pending_withgo throughXAsyncBegintoo, so users, saves, the store). The old call's provider never gets its cleanup either.On the console the state of a call lives in the block's own system area, not in a table by address (as I remember the open-source implementation of this API: it refuses a block whose system area is not zero, and a zeroed block is always a new one). The same test works here: the block of a result left behind holds the result's size in that area, so it never reads zero.
XAsyncBeginnow, when a call is filed under the block's address:Cleanup) and begins the new one;E_INVALIDARG, as before, whatever the block holds;E_INVALIDARG, as before.I have not seen which results the title leaves unfetched (I have no game files).
Tested
Windows 11 Pro 10.0.26200, rustc 1.98.1 (
x86_64-pc-windows-msvc), no game data, no GPU involved.New unit test
a_new_block_where_a_result_was_left_begins_a_call: a provider that completes with one byte to fetch and counts its cleanups.E_INVALIDARG), no cleanup.finished_withbegins (S_OK), the call left behind got exactly one cleanup, and the new call's result (9) is fetched and the call ends.Results:
main(d2a4bae) + the test only:cargo test -p victory-hle --lib a_new_block_wherefails at step 2:left: -2147024809(E_INVALIDARG),right: 0. Step 1 passes.cargo test -p victory-hle --lib: 87 passed, 0 failed (xasync: 6).cargo clippy -p victory-hle --tests: nothing inxasync.rs.rustfmt --check: nothing in the lines changed (existing differences atpending_withand near it).cargo xtask policy: 151 files ok.git merge-tree) with the open PRs on this file, #114, #122, #132, #236 and #239: all clean. #122 and #236 are about a block reused while a call's work or completion is still on its way; this is the entry a fetched-never call leaves filed, which they do not touch.Not tested: a title run.
AI-assisted (Claude Code); the tests above were run on the machine described.
🤖 Generated with Claude Code
@jeremygold02 on GitHub · 2026-11-24 05:28 UTC · original
Tested current PR head
5cff0007a525b83f5c69912d7a38f53c6dafcfef.cargo test --locked -p victory-hle --lib xasync -- --test-threads=1: 6 passed. The newa_new_block_where_a_result_was_left_begins_a_calltest covers the prior completed call whose result was never fetched, same-address reuse with a zeroed new block, preservation of a result-bearing block, and rejection while a call is still in flight. The same target also passed normal result completion, manual and pool callback dispatch, work-result return, and queued cancellation (XAsyncBegin logic, regression test).git diff --check d2a4bae1f49533ef5cb512fd1b1ba1513f2e1989 HEAD: passed.These are unit tests using synthetic providers and async blocks; they do not exercise a real title or runtime integration.