XAsync: a result size of 0 when there is no result to take #2616

Open
F1reworks10 wants to merge 1 commit from upstream-pr/2618 into main
F1reworks10 commented 2026-11-25 16:56:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by F1reworks10 on 2026-11-25T16:56:57Z.


XAsyncGetResultSize only wrote the size when the call had succeeded:

  • While the call was pending, or after it had failed, the caller's variable was left untouched.
  • After the result had been taken, it still reported the old size.

The public reference implementation (libHttpClient's AsyncLib.cpp) writes the size whatever the status:

*bufferSize = state == nullptr ? 0 : state->providerData.bufferSize;
return result;

So the reported size is 0 in three cases:

  • The call is pending: its state's size is not set until completion.
  • The call failed: it has no state.
  • The result was taken: it has no state.

This matters in VIctory because all of its offline answers fail, such as xnetworking's security information and xuser's token and signature. Failure is therefore the normal path for those size queries. A title that sizes its buffer from the reported size before checking the HRESULT reads an uninitialized stack value on main, where the console gives it 0.

Change (crates/victory-hle/src/modules/xasync.rs)

XAsyncGetResultSize always writes a size:

  • the result's size while the call still holds a result (a call stays filed until its result is taken);
  • 0 otherwise.

The returned status is unchanged.

Test

result_size_is_zero_without_a_result_to_take checks the pending, held, taken and failed cases. It fails on main, because a pending call leaves the caller's 0xdeadbeef in place.

cargo test -p victory-hle passes. Clippy is clean with and without --all-features. This PR and #2616 change different parts of xasync.rs and merge cleanly together.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6609446980 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2618). Originally posted by [F1reworks10](https://github.com/F1reworks10) on 2026-11-25T16:56:57Z. --- `XAsyncGetResultSize` only wrote the size when the call had succeeded: - While the call was pending, or after it had failed, the caller's variable was left untouched. - After the result had been taken, it still reported the old size. The public reference implementation ([libHttpClient's `AsyncLib.cpp`](https://github.com/microsoft/libHttpClient/blob/main/Source/Task/AsyncLib.cpp)) writes the size whatever the status: ```cpp *bufferSize = state == nullptr ? 0 : state->providerData.bufferSize; return result; ``` So the reported size is 0 in three cases: - The call is pending: its state's size is not set until completion. - The call failed: it has no state. - The result was taken: it has no state. This matters in VIctory because all of its offline answers fail, such as `xnetworking`'s security information and `xuser`'s token and signature. Failure is therefore the normal path for those size queries. A title that sizes its buffer from the reported size before checking the HRESULT reads an uninitialized stack value on main, where the console gives it 0. ### Change (`crates/victory-hle/src/modules/xasync.rs`) `XAsyncGetResultSize` always writes a size: - the result's size while the call still holds a result (a call stays filed until its result is taken); - 0 otherwise. The returned status is unchanged. ### Test `result_size_is_zero_without_a_result_to_take` checks the pending, held, taken and failed cases. It fails on main, because a pending call leaves the caller's `0xdeadbeef` in place. `cargo test -p victory-hle` passes. Clippy is clean with and without `--all-features`. This PR and #2616 change different parts of `xasync.rs` and merge cleanly together. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kotekompotek commented 2026-11-25 18:02:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:43:51Z.


Reviewed: semantics match the libHttpClient reference — size written unconditionally, 0 when the call is pending/failed/result already taken. call(block).is_some() is the right predicate (the call is filed until its result is taken). Test covers pending/completed/taken states. CI green.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169918032 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2618#issuecomment-7169918032). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:43:51Z. --- Reviewed: semantics match the libHttpClient reference — size written unconditionally, 0 when the call is pending/failed/result already taken. `call(block).is_some()` is the right predicate (the call is filed until its result is taken). Test covers pending/completed/taken states. CI green.
Marvisak commented 2026-11-25 23:06:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:18:08Z.


Automated triage for the maintainers.

Recommended for a maintainer's look. XAsyncGetResultSize in crates/victory-hle/src/modules/xasync.rs now always writes the size: the block's size word while the call is still filed in CALLS, 0 otherwise, matching the cited public libHttpClient reference. I checked against main that a call leaves CALLS via release when it fails or completes with size 0 (complete_call) and when its result is taken (XAsyncGetResult), so "filed" is the right test for "has a result to take"; the returned HRESULT is unchanged. Small, with a test covering pending/held/taken/failed. It also merges alongside #2616 by the author's account (#2616 currently needs a rebase). Merges cleanly, CI check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176191377 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2618#issuecomment-7176191377). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:18:08Z. --- <!-- victory-triage v1 head=21d63c270f58f0f5d92d0381ebc35491427205f0 verdict=merge-candidate at=2026-11-25T22:22:00Z --> Automated triage for the maintainers. Recommended for a maintainer's look. `XAsyncGetResultSize` in `crates/victory-hle/src/modules/xasync.rs` now always writes the size: the block's size word while the call is still filed in `CALLS`, 0 otherwise, matching the cited public libHttpClient reference. I checked against main that a call leaves `CALLS` via `release` when it fails or completes with size 0 (`complete_call`) and when its result is taken (`XAsyncGetResult`), so "filed" is the right test for "has a result to take"; the returned HRESULT is unchanged. Small, with a test covering pending/held/taken/failed. It also merges alongside #2616 by the author's account (#2616 currently needs a rebase). Merges cleanly, CI `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
futurepro62 commented 2026-11-26 02:07:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T01:22:36Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 21d63c2 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: result_size_is_zero_without_a_result_to_take.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7179711841 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2618#issuecomment-7179711841). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T01:22:36Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `21d63c2` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `result_size_is_zero_without_a_result_to_take`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Dukestar69 commented 2026-11-26 06:02:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T05:17:41Z.

Review: APPROVED


Tested locally merged onto origin/main (63bcca4) on Windows 11 x64:

  • Diff review: XAsyncGetResultSize now always writes *out (0 when pending, failed, or after the result has already been taken via call(block).is_some() check, and the recorded result size otherwise), matching libHttpClient's AsyncLib.cpp semantics and preventing callers from reading stale output values.
  • cargo test -p victory-hle xasync: 14 passed, 0 failed (including result_size_is_zero_without_a_result_to_take).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068912737 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2618#pullrequestreview-6068912737). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T05:17:41Z. **Review:** APPROVED --- Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - Diff review: `XAsyncGetResultSize` now always writes `*out` (`0` when pending, failed, or after the result has already been taken via `call(block).is_some()` check, and the recorded result size otherwise), matching libHttpClient's `AsyncLib.cpp` semantics and preventing callers from reading stale output values. - `cargo test -p victory-hle xasync`: 14 passed, 0 failed (including `result_size_is_zero_without_a_result_to_take`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 14:01:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T13:55:01Z.

Review: APPROVED


This matches the public XAsyncGetResultSize reference behavior: returning E_INVALIDARG on null inputs, writing 0 while pending (E_PENDING), after failure/cancellation, when required_size == 0, or once XAsyncGetResult has consumed the call, and returning the held payload size for any non-negative completion status (including S_FALSE).

A small follow-up could also add direct assertions for a successful zero-payload completion, a failed completion given a non-zero required_size, and the null-pointer checks.

Local verification on commit 21d63c270f58 and merged onto origin/main (e42183d9): cargo run --locked -p xtask -- policy (184 files ok), cargo clippy -p victory-hle --all-targets (default and --all-features), xasync:: (13 passed on PR head, 14 passed merged), and the full victory-hle suite (149 passed on PR head, 155 passed, 0 failed merged) all pass. Approving.

<!-- greyfinch-sync:Marvisak/VIctory:review:6075326103 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2618#pullrequestreview-6075326103). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T13:55:01Z. **Review:** APPROVED --- This matches the public `XAsyncGetResultSize` reference behavior: returning `E_INVALIDARG` on null inputs, writing `0` while pending (`E_PENDING`), after failure/cancellation, when `required_size == 0`, or once `XAsyncGetResult` has consumed the call, and returning the held payload size for any non-negative completion status (including `S_FALSE`). A small follow-up could also add direct assertions for a successful zero-payload completion, a failed completion given a non-zero `required_size`, and the null-pointer checks. Local verification on commit `21d63c270f58` and merged onto `origin/main` (`e42183d9`): `cargo run --locked -p xtask -- policy` (184 files ok), `cargo clippy -p victory-hle --all-targets` (`default` and `--all-features`), `xasync::` (`13 passed` on PR head, `14 passed` merged), and the full `victory-hle` suite (`149 passed` on PR head, `155 passed, 0 failed` merged) all pass. Approving.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2618:upstream-pr/2618'
git switch 'upstream-pr/2618'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2618'
git switch 'upstream-pr/2618'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2618'
git switch 'upstream-pr/2618'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2618'
git switch 'main'
git merge --squash 'upstream-pr/2618'
git switch 'main'
git merge --ff-only 'upstream-pr/2618'
git switch 'main'
git merge 'upstream-pr/2618'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2616
No description provided.