Skip to content

XGameSave: refuse an update when no version number is above the highest (#2497) - #2511

Open
Creaa wants to merge 1 commit into
Marvisak:mainfrom
Creaa:hle/xgamesave-version-overflow
Open

Creaa wants to merge 1 commit into
Marvisak:mainfrom
Creaa:hle/xgamesave-version-overflow

Conversation

@Creaa

@Creaa Creaa commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

An update whose container folder holds a stray v18446744073709551615 next to a committed v1 lost the save in release builds: the next version number highest + 1 wrapped to 0, the update committed v0 (not a canonical version, so reads ignore it), returned S_OK and removed v1. In debug builds it panicked on the addition. The update is now refused with NO_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::submit takes the next number with highest.checked_add(1) and returns NO_ACCESS when there is none.
  • Test no_version_above_the_highest_number_is_refused_and_kept: a committed v1 and a stray v18446744073709551615; the update returns NO_ACCESS, the save reads as before, v1 stays and no v0 appears.

Tested

  • Windows 11 build 26300, i7-13700F, RTX 4070, Rust 1.100.0.
  • The new test without the fix: debug panics at the addition (xgamesave.rs:511), release fails with left: 0, right: -2138898430 (S_OK instead of NO_ACCESS). With the fix it passes in both; the 12 xgamesave tests 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 on main 940d32f on this NVIDIA card and are outside this change: victory-gpu dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views; victory-shader a_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 Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744 on an RTX 5070).

Not tested

  • A save folder from a real title with such a stray folder: the case is made by the test. The separate case the issue mentions (a valid manifest with missing blobs) is not changed here.

AI use

  • Claude Code (Claude Opus 5.5) wrote the change and the test, ran them, and drafted this description; I checked it.

🤖 Generated with Claude Code

…st (Marvisak#2497)

With a stray `v18446744073709551615` folder next to a committed `v1`, the
next number `highest + 1` overflowed: a debug build panicked, and a release
build wrapped to 0, committed `v0` (not canonical, so never read), returned
S_OK and removed `v1`, losing the save. The number now comes from
`checked_add`; with none, the update returns NO_ACCESS, as for a container
with no readable version, before anything is written or removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Verification (Windows 11, WARP/CPU only) — head b730d1e5ffd5173146b5ba745cdc3dd4f64c99a9, with overlap against #2525

Tested: the PR head = origin/main 940d32f + the PR (merge-base 940d32f, fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1. VICTORY_D3D12_WARP=1 with --features diagnostics for victory-hle (it enables victory-gpu/diagnostics, so any host device is WARP); the xgamesave code itself is filesystem-only. No physical GPU.

command result
cargo test -p victory-hle --locked --features diagnostics --lib xgamesave -- --test-threads=1 12 passed, 0 failed
... --lib no_version_above 1 passed
same test against origin/main's production code (test kept) fails: panics at xgamesave.rs:511 (highest + 1 overflow; wraps to v0 in a release build, as #2497 describes)
cargo test -p victory-hle --locked --features diagnostics --lib -- --test-threads=1 144 passed, 0 failed, 0 ignored
cargo clippy -p victory-hle --all-targets [--features diagnostics] --locked -- -D warnings clean
cargo xtask policy asset policy: 182 files ok

Diff read: checked_add(1) on highest returns NO_ACCESS before commit/removal, so nothing is written or removed; the no-save path (Some(1)) is unchanged. The test asserts the refusal, that state is unchanged, v1 remains and v0 is never created. No findings.

Side by side with #2525 (head a805860e; both fix #2497, both only touch victory-hle/src/modules/xgamesave.rs)

WARP-only caveat is moot for the filesystem logic; no real GPU used. Synthetic data only.

AI use: Claude Code (Claude Sonnet 5.5).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Merge candidate: in crates/victory-hle/src/modules/xgamesave.rs, Update::submit now takes the next version number with highest.checked_add(1) and returns NO_ACCESS before commit and before the old version is removed. On main, current() counts any v<N> entry (including a stray one) in highest, so highest + 1 really 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

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified against main (63bcca43) on Windows 11 — clean fix for #2497 and ready to merge:

  • Using v.highest.checked_add(1) in Update::submit (crates/victory-hle/src/modules/xgamesave.rs:514-516) returns NO_ACCESS before writing or pruning prior versions when highest == u64::MAX, eliminating both release wraparound to v0 and debug overflow panic.

Local verification:

  • cargo test --locked -p victory-hle: 153/153 unit (including xgamesave 12/12 with no_version_above_the_highest_number_is_refused_and_kept) + 2/2 integration tests passed
  • cargo clippy --all-targets -p victory-hle -- -D warnings + cargo xtask policy (191 files ok): 0 warnings

Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 26, 2026
…no number wraps

Three more ways the committed save could be lost or become unreachable, found
in open PRs of the family and reviewed against our code:

- Removing unfinished or superseded versions no longer fails the read or the
  update. A virus scanner or the search index holding a file open (os errors
  32 and 4395 are seen, the latter when the title is started from an app whose
  AppData is a redirected package copy) made `remove_dir_all(...)?` fail, and
  `containers` then dropped the container: the title saw no save and started
  a new game. The stale folder now stays for the next look; committing a
  version retries for up to a second where Windows reports the folder held
  (PR Marvisak#1838, adamMasMusic; same defect as BESTegolol ca800f5434).
- A version counts only if every blob its manifest names is a file there. A
  newer version left without a blob (a crash, a partial copy) used to win and
  the last complete one was removed (PR Marvisak#1981, WerG0D).
- A stray `v18446744073709551615` left no number above it: `+ 1` wrapped to
  `v0`, which is not read, and the update then removed the committed version.
  Such an update is refused before anything is written (PR Marvisak#2511, Creaa).

Each comes with its test. Nothing here deletes more than before: every
removal that remains happens after the surviving version was read whole.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
@cloph-dsp

Copy link
Copy Markdown

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 --check against merge base 940d32f — clean.
  • Per-worktree CARGO_TARGET_DIR used.

AI-assisted (Hy4 flash). GPU/driver: N/A (CPU only). Did not replay a real title save.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XGameSave: a stray v18446744073709551615 folder makes an update lose the save in release builds (follow-up to #1729)

5 participants