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

Open
github-bot wants to merge 1 commit from github-bot/gh-2618 into main AGit
Owner

@⁠F1reworks10 on GitHub · 2026-11-25 16:56 UTC · original
F1reworks10:xasync-result-size-without-result → main · +63 −5 · 1 files · 1 commits · open

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

**@⁠F1reworks10** on GitHub · 2026-11-25 16:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2618) `F1reworks10:xasync-result-size-without-result` → `main` · +63 −5 · 1 files · 1 commits · open `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)
What was wrong: XAsyncGetResultSize wrote the size only for a call that
succeeded. While a call was pending or after it failed, the caller's
variable was left as it was, and after the result was taken it still
read the old size. The public reference (libHttpClient's AsyncLib.cpp)
writes the size whatever the status: that of the result the call still
holds, 0 without one. A title that sizes a buffer from it before looking
at the status read whatever was on its stack, and every one of our
offline answers fails (network security information, user tokens), so
that is the path such a size query takes here.

What changed: XAsyncGetResultSize always writes the size: the result's
while the call holds one (it is filed until its result is taken), else
0. The status it returns is unchanged.

Evidence: `result_size_is_zero_without_a_result_to_take` fails on main
(a pending call leaves the caller's 0xdeadbeef in place) and checks the
pending, held, taken and failed cases. `cargo test -p victory-hle`
passes; clippy (with and without --all-features) is clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:28 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:43 UTC · original

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.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2618#issuecomment-7169918032) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:18 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2618#issuecomment-7176191377) <!-- 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)_
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 01:22 UTC · original

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.
**@⁠futurepro62** on GitHub · 2026-11-26 01:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2618#issuecomment-7179711841) 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.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 05:17 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-26 05:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2618#pullrequestreview-6068912737) · **approved these changes** 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 13:55 UTC · original · approved these changes

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 13:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2618#pullrequestreview-6075326103) · **approved these changes** 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2618/head:github-bot/gh-2618'
git switch 'github-bot/gh-2618'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2618'
git switch 'github-bot/gh-2618'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2618'
git switch 'github-bot/gh-2618'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2618'
git switch 'main'
git merge --squash 'github-bot/gh-2618'
git switch 'main'
git merge --ff-only 'github-bot/gh-2618'
git switch 'main'
git merge 'github-bot/gh-2618'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2618
No description provided.