HLE: preserve non-S_OK success HRESULTs in xasync::finished #3132

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

@⁠fuzeofficlal on GitHub · 2026-11-26 09:32 UTC · original
fuzeofficlal:fix/hle-xasync-finished-status → main · +54 −16 · 1 files · 1 commits · open

Summary

xasync::finished (crates/victory-hle/src/modules/xasync.rs) is documented to complete an AsyncBlock with the caller-supplied HRESULT and no payload, and XAsyncGetResultSize explicitly treats nonnegative statuses such as S_FALSE (1) as valid completion codes.

Previously, finished mapped every nonnegative value to Ok(Vec::new()) in finished_with, whose OP_BEGIN handler overwrote every Ok result with S_OK (0), silently turning S_FALSE and other positive HRESULT codes into S_OK.

Fix

  • Extract an internal finished_status helper shared by finished and finished_with (keeping both public signatures unchanged) so finished forwards hr directly while finished_with(Ok(bytes)) continues to complete with S_OK.
  • Add synthetic regression test finished_preserves_the_completion_status verifying S_FALSE, positive HRESULT, S_OK, and E_ABORT across XAsyncGetStatus, XAsyncGetResultSize, and XAsyncGetResult.

Verification

  • cargo test -p victory-hle --locked: 153 lib + 1 fidelityfx + 1 no_dll_planting passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings and --all-features: clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 09:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/3132) `fuzeofficlal:fix/hle-xasync-finished-status` → `main` · +54 −16 · 1 files · 1 commits · open ## Summary `xasync::finished` (`crates/victory-hle/src/modules/xasync.rs`) is documented to complete an `AsyncBlock` with the caller-supplied `HRESULT` and no payload, and `XAsyncGetResultSize` explicitly treats nonnegative statuses such as `S_FALSE` (`1`) as valid completion codes. Previously, `finished` mapped every nonnegative value to `Ok(Vec::new())` in `finished_with`, whose `OP_BEGIN` handler overwrote every `Ok` result with `S_OK` (`0`), silently turning `S_FALSE` and other positive `HRESULT` codes into `S_OK`. ## Fix - Extract an internal `finished_status` helper shared by `finished` and `finished_with` (keeping both public signatures unchanged) so `finished` forwards `hr` directly while `finished_with(Ok(bytes))` continues to complete with `S_OK`. - Add synthetic regression test `finished_preserves_the_completion_status` verifying `S_FALSE`, positive `HRESULT`, `S_OK`, and `E_ABORT` across `XAsyncGetStatus`, `XAsyncGetResultSize`, and `XAsyncGetResult`. ## Verification - `cargo test -p victory-hle --locked`: 153 lib + 1 fidelityfx + 1 no_dll_planting passed, 0 failed. - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` and `--all-features`: clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: passed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:08:12 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 09:48 UTC · original

Independent local verification of head 52d69c7 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-hle --lib modules::xasync::tests::finished_preserves_the_completion_status — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

Synthetic HLE inputs only; no game assets, extracted data or DRM material used. AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-26 09:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3132#issuecomment-7188492014) Independent local verification of head `52d69c7` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-hle --lib modules::xasync::tests::finished_preserves_the_completion_status` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. Synthetic HLE inputs only; no game assets, extracted data or DRM material used. AI-assisted (Hy4 flash).
Author
Owner

@⁠AurumCarlos on GitHub · 2026-11-26 12:42 UTC · original · reviewed

Looks correct to me. I traced each path through finished_status against main:

  • finished(hr < 0) and finished_with(Err(hr)) → Data { hr, bytes: [] }. This completes with hr and size 0, the same as before.
  • finished_with(Ok(bytes)) → S_OK with the payload. Also the same as before.
  • finished(hr >= 0) → now completes with hr itself instead of S_OK. That's the fix. With size 0, complete_call releases the call right away, and XAsyncGetResult returns hr early with used = 0, which is what the test checks.
  • OP_GET_RESULT now copies bytes without checking for an error, but it's only reached for hr >= 0 with a nonzero size (XAsyncGetResult returns early otherwise), and on the error path bytes is empty anyway. So that's fine.

One thing worth adding to the description, for whoever merges: no in-tree caller passes a positive HRESULT to finished today. Of the 11 calls on main, 7 pass constants that are S_OK or failures (UNREACHABLE, NO_PACKAGE, NETWORK_ERROR, FAILED_TO_GET_TOKEN, E_ILLEGAL_METHOD_CALL). The other four compute it, and I didn't trace those (delete/Update::submit in xgamesave, storage's prompt result). Nothing in victory-hle outside xasync uses S_FALSE, so this most likely fixes the contract for a future caller rather than changing anything a title sees today. Saying so would make the change easier to merge.

Nit: in the test, (2, 0) could use a named const or a short comment (e.g. "any other success code"), so it doesn't read like a magic number next to S_FALSE.

This PR and #3195 both touch xasync.rs, in different hunks (finished* here, complete_call there), so they should merge cleanly in either order.

**@⁠AurumCarlos** on GitHub · 2026-11-26 12:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3132#pullrequestreview-6074302244) · **reviewed** Looks correct to me. I traced each path through `finished_status` against `main`: - `finished(hr < 0)` and `finished_with(Err(hr))` → `Data { hr, bytes: [] }`. This completes with `hr` and size 0, the same as before. - `finished_with(Ok(bytes))` → `S_OK` with the payload. Also the same as before. - `finished(hr >= 0)` → now completes with `hr` itself instead of `S_OK`. That's the fix. With size 0, `complete_call` releases the call right away, and `XAsyncGetResult` returns `hr` early with `used = 0`, which is what the test checks. - `OP_GET_RESULT` now copies `bytes` without checking for an error, but it's only reached for `hr >= 0` with a nonzero size (`XAsyncGetResult` returns early otherwise), and on the error path `bytes` is empty anyway. So that's fine. One thing worth adding to the description, for whoever merges: **no in-tree caller passes a positive `HRESULT` to `finished` today.** Of the 11 calls on `main`, 7 pass constants that are `S_OK` or failures (`UNREACHABLE`, `NO_PACKAGE`, `NETWORK_ERROR`, `FAILED_TO_GET_TOKEN`, `E_ILLEGAL_METHOD_CALL`). The other four compute it, and I didn't trace those (`delete`/`Update::submit` in xgamesave, `storage`'s prompt result). Nothing in `victory-hle` outside `xasync` uses `S_FALSE`, so this most likely fixes the contract for a future caller rather than changing anything a title sees today. Saying so would make the change easier to merge. Nit: in the test, `(2, 0)` could use a named const or a short comment (e.g. "any other success code"), so it doesn't read like a magic number next to `S_FALSE`. This PR and #3195 both touch `xasync.rs`, in different hunks (`finished*` here, `complete_call` there), so they should merge cleanly in either order.
This pull request can be merged automatically.
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/3132/head:github-bot/gh-3132'
git switch 'github-bot/gh-3132'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3132'
git switch 'github-bot/gh-3132'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3132'
git switch 'github-bot/gh-3132'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3132'
git switch 'main'
git merge --squash 'github-bot/gh-3132'
git switch 'main'
git merge --ff-only 'github-bot/gh-3132'
git switch 'main'
git merge 'github-bot/gh-3132'
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!3132
No description provided.