HLE: preserve non-S_OK success HRESULTs in xasync::finished #3132
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!3132
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3132"
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?
@fuzeofficlal on GitHub · 2026-11-26 09:32 UTC · original
fuzeofficlal:fix/hle-xasync-finished-status→main· +54 −16 · 1 files · 1 commits · openSummary
xasync::finished(crates/victory-hle/src/modules/xasync.rs) is documented to complete anAsyncBlockwith the caller-suppliedHRESULTand no payload, andXAsyncGetResultSizeexplicitly treats nonnegative statuses such asS_FALSE(1) as valid completion codes.Previously,
finishedmapped every nonnegative value toOk(Vec::new())infinished_with, whoseOP_BEGINhandler overwrote everyOkresult withS_OK(0), silently turningS_FALSEand other positiveHRESULTcodes intoS_OK.Fix
finished_statushelper shared byfinishedandfinished_with(keeping both public signatures unchanged) sofinishedforwardshrdirectly whilefinished_with(Ok(bytes))continues to complete withS_OK.finished_preserves_the_completion_statusverifyingS_FALSE, positiveHRESULT,S_OK, andE_ABORTacrossXAsyncGetStatus,XAsyncGetResultSize, andXAsyncGetResult.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 warningsand--all-features: clean.cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.@cloph-dsp on GitHub · 2026-11-26 09:48 UTC · original
Independent local verification of head
52d69c7on 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).
@AurumCarlos on GitHub · 2026-11-26 12:42 UTC · original · reviewed
Looks correct to me. I traced each path through
finished_statusagainstmain:finished(hr < 0)andfinished_with(Err(hr))→Data { hr, bytes: [] }. This completes withhrand size 0, the same as before.finished_with(Ok(bytes))→S_OKwith the payload. Also the same as before.finished(hr >= 0)→ now completes withhritself instead ofS_OK. That's the fix. With size 0,complete_callreleases the call right away, andXAsyncGetResultreturnshrearly withused = 0, which is what the test checks.OP_GET_RESULTnow copiesbyteswithout checking for an error, but it's only reached forhr >= 0with a nonzero size (XAsyncGetResultreturns early otherwise), and on the error pathbytesis empty anyway. So that's fine.One thing worth adding to the description, for whoever merges: no in-tree caller passes a positive
HRESULTtofinishedtoday. Of the 11 calls onmain, 7 pass constants that areS_OKor 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::submitin xgamesave,storage's prompt result). Nothing invictory-hleoutsidexasyncusesS_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 toS_FALSE.This PR and #3195 both touch
xasync.rs, in different hunks (finished*here,complete_callthere), so they should merge cleanly in either order.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.