XGameSave recovery can delete a valid save when v01 and v1 coexist #870
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#870
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@THE-PRO-GAME on GitHub · 2026-11-24 13:00 UTC · original
Save recovery can delete a committed save if its container also contains a leftover directory named
v01. The scan parses bothv01andv1as version 1. When it cleans up what it considers an older version, it reconstructs the name asv1and deletes the committed save.I reproduced this on upstream
ffe310eusing a synthetic save in a temporary directory. The regression test writes a validv1, creates an emptyv01, and reads the save. Before the fix, the read removesv1. After the fix, the original save is still readable and both directories remain.The patch makes recovery recognize only the canonical version names written by the save system. The commit includes the regression test. Patch and regression test
Related to the broader audit in #810. I used Codex and verified the reproduction with synthetic inputs on Windows 11.
@DenRakEiw on GitHub · 2026-11-24 14:15 UTC · original
Independent Windows 11 verification of
27491af(THE-PRO-GAME/VIctory) on Windows 11 x64 (Rust 1.98.1 MSVC):cargo test -p victory-hle a_noncanonical_directory_does_not_remove_a_committed_save: passedcargo test -p victory-hle xgamesave: 9 passed, 0 failedcargo clippy -p victory-hle --all-targets: 0 warningscargo xtask policy: ok(Small note for maintainers: commit
27491afitself is stacked on a branch with other commits touchingtranslate.rs/config.rs/texture.rs/cache.rs, so cherry-picking27491afcleanly isolates thexgamesave.rsfix.)AI-assisted (Gemini 4 Neon).
@wbnm77 on GitHub · 2026-11-24 14:18 UTC · original
Independent native Windows 10 Pro x64 22H2 run on Ryzen 7 5700X with Rust 1.98.1 MSVC. I applied only the synthetic regression test to upstream
ffe310eb2098e52169f4c44db5ffdabf43a72622. Runninga_noncanonical_directory_does_not_remove_a_committed_savefailed withthe committed save was removed.On fork commit
27491af5b8b2b53f24b4e97f608f80a314113f6b,cargo test --offline --locked -p victory-hle --lib modules::xgamesave::tests:: -- --nocapturepassed all nine save tests, including the regression. Applying only the canonical-name parser change and the same test to upstreamffe310ealso passed all eight save tests in that tree. All saves were generated in temporary directories. Codex (GPT-6) assisted with setup, running the tests and drafting this report.@NATON4 on GitHub · 2026-11-24 14:56 UTC · original
Opened #1006 for this: one commit on
ffe310e,xgamesave.rsonly. Recovery now treats onlyv<N>exactly ascommitwrites it (no sign, no leading zeros) as a version;v01/v001/v+1are neither counted nor removed. Regression test included. Thanks @THE-PRO-GAME for the report and repro.@winne42 on GitHub · 2026-11-24 20:16 UTC · original
I tested the fixes for this issue as Windows builds under Wine 10.0. Note that all three PRs (#1006, #1035, #1102) were closed by their own authors without being merged, so nothing open currently fixes this.
The name fix works in all three. #1102's code is the same as THE-PRO-GAME's
27491af, which doesn't cherry-pick alone, because it's stacked on1bd9a93. Each PR's own tests pass, and its new test fails when the name check is reverted. clippy is clean.A stray folder with a correct name still loses the save, and #870's fix doesn't cover that. I committed a real
v1, added a stray entry next to it, then calledread():v1mainec2cff0(THE-PRO-GAME/VIctory#2)v01,v+1,v001,v02(empty, or a copy ofv1)v1deletedv2: empty folder, a file, or a corrupt manifestv1deletedv1deletedThe empty-
v2case is worse than a failed read. Onmainand on all three PRs, the next save returnsS_OKbut commits a freshv1holding only the changed blobs. The following read then prunes thatv1too, becausev2still counts as newer. The title is told every save succeeded while nothing survives.With
ec2cff0the data is kept, butsubmitreturnsNO_ACCESS(0x80830002) until the stray folder is removed.Suggestion: land the name check together with
ec2cff0, so recovery never deletes a version before a newer one has been read successfully. A fuller fix would be forcurrent()to use the newest version whose manifest parses, prune only versions below it, and number the next commit above the highestv<N>folder. That way a broken or stray newer folder neither hides the save nor blocks writes.AI-assisted (Claude Code). Tests were synthetic, using temporary directories, with no game files.