XGameSave: refuse an update when no version number is above the highest (#2497) #2509
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2511"
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?
Imported from Marvisak/VIctory. Originally posted by Creaa on 2026-11-25T15:03:54Z.
An update whose container folder holds a stray
v18446744073709551615next to a committedv1lost the save in release builds: the next version numberhighest + 1wrapped to 0, the update committedv0(not a canonical version, so reads ignore it), returnedS_OKand removedv1. In debug builds it panicked on the addition. The update is now refused withNO_ACCESS(what an unreadable container already returns) before anything is written or removed. Fixes #2497.What is in it
crates/victory-hle/src/modules/xgamesave.rs:Update::submittakes the next number withhighest.checked_add(1)and returnsNO_ACCESSwhen there is none.no_version_above_the_highest_number_is_refused_and_kept: a committedv1and a strayv18446744073709551615; the update returnsNO_ACCESS, the save reads as before,v1stays and nov0appears.Tested
xgamesave.rs:511), release fails withleft: 0, right: -2138898430(S_OKinstead ofNO_ACCESS). With the fix it passes in both; the 12xgamesavetests pass in debug and release.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo test --workspace --locked --no-fail-fast: 697 passed, 5 failed, 10 ignored. The 5 fail the same way onmain940d32fon this NVIDIA card and are outside this change:victory-gpudynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views;victory-shadera_heap_buffer_read_by_element_takes_the_views_stride,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,gathers_at_a_level_match_the_hardware(the same five as in #1744 on an RTX 5070).Not tested
AI use
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T15:37:34Z.
Verification (Windows 11, WARP/CPU only) — head
b730d1e5ffd5173146b5ba745cdc3dd4f64c99a9, with overlap against #2525Tested: 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(it enablesvictory-gpu/diagnostics, so any host device is WARP); the xgamesave code itself is filesystem-only. No physical GPU.cargo test -p victory-hle --locked --features diagnostics --lib xgamesave -- --test-threads=1... --lib no_version_aboveorigin/main's production code (test kept)xgamesave.rs:511(highest + 1overflow; wraps tov0in a release build, as #2497 describes)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:
checked_add(1)onhighestreturnsNO_ACCESSbeforecommit/removal, so nothing is written or removed; the no-save path (Some(1)) is unchanged. The test asserts the refusal, thatstateis unchanged,v1remains andv0is never created. No findings.Side by side with #2525 (head
a805860e; both fix #2497, both only touchvictory-hle/src/modules/xgamesave.rs)numberline inUpdate: both usehighest.checked_add(1)withNO_ACCESSand the same intent; the two PRs conflict textually there (git merge conflict in that hunk only; their tests and #2525's other hunks merge cleanly).diagnostics) is clean. So the two overlap fully on the overflow guard and tests; #2511 is the minimal version.load(a version whose listed blob files are missing or not files reads as unreadable), makesmigratestop (returnsNone) when a directory entry or blob read fails instead of silently skipping that blob, and extendsan_unreadable_newer_version_does_not_cost_the_savewith a "missing blob" case (fails onorigin/main). That is beyond #2497's overflow and is not in this PR.WARP-only caveat is moot for the filesystem logic; no real GPU used. Synthetic data only.
AI use: Claude Code (Claude Sonnet 5.5).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:52:45Z.
Automated triage for the maintainers. Merge candidate: in
crates/victory-hle/src/modules/xgamesave.rs,Update::submitnow takes the next version number withhighest.checked_add(1)and returnsNO_ACCESSbeforecommitand before the old version is removed. On main,current()counts anyv<N>entry (including a stray one) inhighest, sohighest + 1really does overflow as described in #2497, and the new test covers that case. CI (check) passes. Note: #2525 changes the same line the same way and also handles missing blobs, so only one of the two should be merged.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:08:28Z.
Review: COMMENTED
Reviewed and verified against
main(63bcca43) on Windows 11 — clean fix for #2497 and ready to merge:v.highest.checked_add(1)inUpdate::submit(crates/victory-hle/src/modules/xgamesave.rs:514-516) returnsNO_ACCESSbefore writing or pruning prior versions whenhighest == u64::MAX, eliminating both release wraparound tov0and debug overflow panic.Local verification:
cargo test --locked -p victory-hle: 153/153 unit (includingxgamesave12/12 withno_version_above_the_highest_number_is_refused_and_kept) + 2/2 integration tests passedcargo clippy --all-targets -p victory-hle -- -D warnings+cargo xtask policy(191 files ok): 0 warningsImported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T15:17:25Z.
Independent verification (Windows, Rust 1.100.0/MSVC, head
b730d1e, synthetic save directories only, no game data):cargo test --locked -p victory-hle --lib -- modules::xgamesave::tests::no_version_above_the_highest_number_is_refused_and_kept --exact— 1 passed, 0 failed, 143 filtered.git diff --checkagainst merge base940d32f— clean.CARGO_TARGET_DIRused.AI-assisted (Hy4 flash). GPU/driver: N/A (CPU only). Did not replay a real title save.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T01:30:53Z.
Review: APPROVED
LGTM — verified on Windows:
v.highest.checked_add(1)and returningNO_ACCESScleanly preventsu64::MAX + 1wraparound tov0and preserves the committed savecargo test -p victory-hle --lib xgamesavepassed (12/12, includingno_version_above_the_highest_number_is_refused_and_kept)cargo clippy -p victory-hle --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (191 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.