HLE: guard XGameSave version overflow and validate blobs before removing older versions #2525
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!2525
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2525/head"
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?
@reeledMarek on GitHub · 2026-11-25 15:16 UTC · original
reeledMarek:fix/hle-xgamesave-data-loss→main· +53 −13 · 1 files · 1 commits · closed without mergingFixes #2497
Problem
Update::submitcomputedv.highest + 1. With a strayv18446744073709551615(u64::MAX) folder next to a committedv1, debug builds panic and release builds wrap tov0(ignored on read), returnS_OK, and deletev1.load(dir)only verifiedmanifestwithout checking that each listed blob file0..blobs.len()exists as a regular file, so a newer version folder with a valid manifest and missing blob causedcurrent()to delete intact older versions.migrate()usedfilter_mapwithstd::fs::read(e.path()).ok()?, silently omitting unreadable blobs before committingv1and deleting the legacy folder.Fix
v.highest.checked_add(1)inUpdate::submit, returningNO_ACCESSon overflow before writing or deleting anything.load(dir)(returningOk(None)if missing/non-file, propagating other I/O errors).migrate()without deleting the legacy folder if any blob fails to read.Testing
an_unreadable_newer_version_does_not_cost_the_savewith amissing blobcase and addedstray_u64_max_version_does_not_lose_the_saveincrates/victory-hle/src/modules/xgamesave.rs.cargo test -p xtask --lockedpasses asset policy.@oni-swr on GitHub · 2026-11-25 15:37 UTC · original
Verification (Windows 11, WARP/CPU only) — head
a805860e302d2dbc8db9218cca5ae9b577d82039, with overlap against #2511Tested: the PR head =
origin/main940d32f+ the PR (merge-base940d32f, fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1.VICTORY_D3D12_WARP=1with--features diagnosticsforvictory-hle(WARP for any host device; xgamesave itself is filesystem-only). No physical GPU.cargo test -p victory-hle --locked --features diagnostics --lib xgamesave -- --test-threads=1... --lib stray_u64_maxorigin/main's production code (tests kept)xgamesave.rs:511(highest + 1overflow)... --lib an_unreadable_newer(new "missing blob" case)origin/main's production code (panic atxgamesave.rs:1038)cargo test -p victory-hle --locked --features diagnostics --lib -- --test-threads=1cargo clippy -p victory-hle --all-targets [--features diagnostics] --locked -- -D warningscargo xtask policyasset policy: 182 files okDiff read: the
checked_addguard is the same as #2511's.loadnow stats each listed blob (0..n) and treats a missing or non-file blob as an unreadable version, so such a version is no longer picked as current and older versions are not removed behind it;migratenow aborts (None) on a failingread_direntry or blob read instead of skipping it. Observations, not blockers: (1) themigratechange is a behaviour change with no test of its own (one permanently unreadable entry now blocks migrating that folder, where before the blob was dropped silently); (2)loadnow costs onemetadatacall per blob per version scanned; (3) only existence/is_fileis checked, not size.Side by side with #2511 (head
b730d1e5): the overflow guard is the same single line (checked_add(1)->NO_ACCESS); the two conflict textually at that hunk only. Resolving it with either side and both PRs' tests: 13 xgamesave tests pass; with this PR's side, full lib 145 passed, 0 failed and clippy clean. This PR is a superset of #2511 (adds blob validation inload, the strictermigrate, and one more test case); #2511 is just the overflow fix.AI use: Claude Code (Claude Sonnet 5.5).
@Marvisak on GitHub · 2026-11-25 15:54 UTC · original
Automated triage for the maintainers. Merge candidate (a recommendation to look, not an approval).
In crates/victory-hle/src/modules/xgamesave.rs this fixes #2497 (
Update::submitnow refuses withNO_ACCESSwhenhighest + 1would overflow, instead of committing an unreadv0and removingv1), makesloadtreat a version whose listed blob files0..nare missing as unreadable socurrentno longer removes older versions behind it (the second case named in #2497), and makesmigratekeep the legacy folder when a blob fails to read instead of dropping that blob and deleting the folder. The overflow hunk is the same as #2511, which this PR includes, so only one of the two should land; themigratechange has no test of its own. CI: thecheckjob passes.Generated by Claude Code
v18446744073709551615folder makes an update lose the save in release builds (follow-up to #1729) #2497@Marvisak on GitHub · 2026-11-25 22:10 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing as covered by two other PRs: the
loadhunk is #1981's with fewer tests, and the overflow hunk is #2511's line. Themigratechange is untested and protects nothing: once the title saves under that name, the next provider open finds the new layout committed and deletes the legacy folder anyway.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed