startup: reject new updates on a closed save container #1969

Merged
avt0m4t48 merged 1 commit from upstream-pr/1976 into main 2026-11-24 22:34:32 +00:00
avt0m4t48 commented 2026-11-24 22:27:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by avt0m4t48 on 2026-11-24T22:27:00Z.


Refs #1200. A pending update pins the container name until that update ends. Creating another update requires a live container reference, so use the reference count for that check. The source-built fixture closes a container while its first update is open, checks that the first update still resolves the pinned name, and checks that the closed container cannot start a second update.

g++ -std=c++17 -O2 -Wall -Wextra -pedantic -pthread -Isrc/startup_stubs tests/startup_gamesave_persist.cpp -o <test> followed by running the binary passed on Linux (GCC 14.2). The added assertion fails on the original save_store.h. The focused save enumeration, cross-process publication, lock and blob-packing controls also passed. Windows provider execution and the reported second-start setup behavior remain unverified.

Source-built inputs only. AI-assisted using Codex.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592658118 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1976). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T22:27:00Z. --- Refs #1200. A pending update pins the container name until that update ends. Creating another update requires a live container reference, so use the reference count for that check. The source-built fixture closes a container while its first update is open, checks that the first update still resolves the pinned name, and checks that the closed container cannot start a second update. `g++ -std=c++17 -O2 -Wall -Wextra -pedantic -pthread -Isrc/startup_stubs tests/startup_gamesave_persist.cpp -o <test>` followed by running the binary passed on Linux (GCC 14.2). The added assertion fails on the original `save_store.h`. The focused save enumeration, cross-process publication, lock and blob-packing controls also passed. Windows provider execution and the reported second-start setup behavior remain unverified. Source-built inputs only. AI-assisted using Codex.
upstream-sync closed this pull request 2026-11-24 23:03:22 +00:00
ChazY11 commented 2026-11-24 23:03:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:30:29Z.


Built and ran it on Windows/MSVC — the platform the description leaves unverified

Windows 11 build 26300.9974, MSVC 19.44, dev preset:

cmake --build --preset dev --target startup_gamesave_persist    # exit 0
ctest --preset dev -R '^startup_gamesave_persist$'
1/10 Test #110: startup_gamesave_persist ... Passed 1.42 sec

(The other nine gamesave entries in that filter report "Not Run" because they need executables I did not build — my selection, not
the PR.)

Two mutations, both caught

mutation result
refs_[container] == 0 → names_[container].empty() (the original check) caught
container >= capacity || refs_[container] == 0 → container >= capacity only caught

The first is the one that matters: it is the pre-change line, so the fixture genuinely fails without the fix rather than merely
passing with it. The second shows the reference-count check is not decorative — dropping it accepts a closed container with a name
still pinned by the pending update.

Why the reference count is the right predicate here

A pending update keeps the name alive after the container is closed, so names_[container].empty() answers "does this slot have a
name", not "can I start an update". Using refs_ asks the question the caller actually needs, and the fixture's sequence — open,
start update, close, resolve the pinned name, then try a second update — is the shortest one that distinguishes the two.

What is unverified

The Windows provider path and the reported second-start behaviour, as the description says, are not exercised here; the fixture is a
host-side model of the store. Whether the real provider pins the name across a close is a claim about the provider, not about this
header.

Verdict

Reviewed. One-line change, the fixture fails on the old line, and both halves of the condition are pinned.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146312329 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1976#issuecomment-7146312329). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:30:29Z. --- ## Built and ran it on Windows/MSVC — the platform the description leaves unverified Windows 11 build 26300.9974, MSVC 19.44, `dev` preset: ```powershell cmake --build --preset dev --target startup_gamesave_persist # exit 0 ctest --preset dev -R '^startup_gamesave_persist$' 1/10 Test #110: startup_gamesave_persist ... Passed 1.42 sec ``` (The other nine `gamesave` entries in that filter report "Not Run" because they need executables I did not build — my selection, not the PR.) ## Two mutations, both caught | mutation | result | |---|---| | `refs_[container] == 0` → `names_[container].empty()` (the original check) | **caught** | | `container >= capacity \|\| refs_[container] == 0` → `container >= capacity` only | **caught** | The first is the one that matters: it is the pre-change line, so the fixture genuinely fails without the fix rather than merely passing with it. The second shows the reference-count check is not decorative — dropping it accepts a closed container with a name still pinned by the pending update. ## Why the reference count is the right predicate here A pending update keeps the name alive after the container is closed, so `names_[container].empty()` answers "does this slot have a name", not "can I start an update". Using `refs_` asks the question the caller actually needs, and the fixture's sequence — open, start update, close, resolve the pinned name, then try a second update — is the shortest one that distinguishes the two. ## What is unverified The Windows provider path and the reported second-start behaviour, as the description says, are not exercised here; the fixture is a host-side model of the store. Whether the real provider pins the name across a close is a claim about the provider, not about this header. ## Verdict Reviewed. One-line change, the fixture fails on the old line, and both halves of the condition are pinned. ## Notes - AI-assisted review.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1969
No description provided.