XAsync: a new block where a result was left behind begins a call #247
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/247"
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 Marvisak/VIctory. Originally posted by Maraco91 on 2026-11-24T01:46:10Z.
What
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
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T05:28:09Z.
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.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:55:09Z.
Review: APPROVED
Tested
5cff000on Windows 11, RTX 5070, MSVC: the workspace passes (196 outsidevictory-shader), includinga_new_block_where_a_result_was_left_begins_a_call.CALLSby address, and a fresh, zeroed block the allocator places at the same address can then never begin a call.done) whose block is all-zero again can only be a new block, because a block holding a result has its size word set. An in-flight call (!done) is always refused, as the test's last part shows.releaseruns the left-behind call's cleanup, which was never run before.donestill means "status published" there.No issues found.
AI-assisted (Claude Code).