startup: list save containers and blobs under the shared publication lock #1754

Merged
tedin7 merged 3 commits from upstream-pr/1761 into main 2026-11-24 19:08:55 +00:00
tedin7 commented 2026-11-24 18:11:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:11:44Z.


Part of the split of #1334 (enumeration, store only). No slot wiring: runtime_proxy.cpp, save_read.inl and the docs are untouched, so this does not overlap #1429 or the #1334 draft's slot code. The slot wiring (13, 14, 18, 20) is the next slice, after this one.

Change

Store in src/startup_stubs/save_store.h gets two read-only methods and two entry types:

  • list_containers(std::vector<ContainerEntry>&): directories directly below the root, by name (byte order). Links and junctions, plain files, and names valid_name refuses (lock, staging and old suffixes in any case) are not listed. A root that does not exist yet lists as empty.
  • list_blobs(container, std::vector<BlobEntry>&): name and size of the regular files of one container, by name. It is taken under the shared lock_container, the publication point read_blobs uses, so a commit from another process is listed whole or not at all. After acquiring the shared lock, list_blobs re-checks the container directory status so a concurrent delete_container or redirect swap while waiting for the lock reports not_found or bad_name rather than io_error. not_found for a missing container, bad_name for an invalid or redirected one, busy when the lock stays held for the whole timeout, too_large for a blob over max_blob_bytes.
  • out is replaced only on ok; on every other status it is left as the caller had it. No partial output.
  • No timestamps: that is a separate decision (the old #1334 commit used a process-local mutex, which a second process does not honour, and a clock conversion).

Test

tests/startup_gamesave_enumerate.cpp (plain C++17, synthetic data, registered next to startup_gamesave_persist). It covers:

  • exact names, sizes and order for two and five containers and three blobs, written out of order; a repeated listing gives the same answer;
  • not listed: .x2w-part, .x2w-old, .x2w-lock (also .X2W-PART), a name with .., a subdirectory, a plain file or lock directory in the root, a linked blob and a linked container (the link controls are skipped with a printed note where the platform refuses to create one);
  • not_found, bad_name, io_error (regular-file container / regular-file root), redirected root, empty root and empty container, too_large over the limit and the exact limit listed, all verifying out is untouched on non-ok status;
  • across processes (the test starts itself):
    • a child holds the exclusive lock, list_blobs returns busy after the timeout with the output untouched and another container still lists; after release the call succeeds;
    • a child holds the exclusive lock and deletes the container directory before releasing, list_blobs returns not_found (not io_error) with the output untouched;
    • a child publishes 300 two-blob generations through commit while this process lists in a loop: every listing has both blobs at one size, none fails, and it saw more than one generation.

Results

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at ccba9fcf9b0f858b9afc39130fa92d97024885d0

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_shim startup_gameinput_history startup_gameinput_keys startup_gamesave_enumerate startup_gamesave_persist startup_gamesave_publish_locked startup_gamesave_publish_unlocked startup_stream_consumer startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xmem_shim -- -j 8): 6.18s (configure 1.71s)
    • Test (ctest --preset dev -R '^(startup_gameinput_history|startup_gameinput_keys|startup_gamesave_enumerate|startup_gamesave_persist|startup_gamesave_publish_locked|startup_gamesave_publish_unlocked|startup_storage_directory_batch|startup_stubs)$' --parallel 6 --no-tests=error --output-on-failure): 8/8 passed (2.33s: startup_gamesave_enumerate 1.70s, startup_gamesave_persist 0.79s, startup_gamesave_publish_locked 2.19s, startup_gamesave_publish_unlocked 1.02s, startup_stubs 0.70s, startup_storage_directory_batch 0.20s, startup_gameinput_history 0.05s, startup_gameinput_keys 0.03s)
  • Release /O2 (--preset release):
    • Build (same targets): 8.66s (configure 1.71s)
    • Test (same regex): 8/8 passed (2.26s: startup_gamesave_enumerate 1.27s, startup_gamesave_persist 0.65s, startup_gamesave_publish_locked 2.13s, startup_gamesave_publish_unlocked 0.99s, startup_stubs 0.53s, startup_storage_directory_batch 0.21s, startup_gameinput_history 0.05s, startup_gameinput_keys 0.03s)
  • Mutations verified on Windows Server 2025 (startup_gamesave_enumerate, Debug):
    • Shared lock removed from list_blobs: FAIL (5 checks failed: busy, busy output untouched, busy timeout, concurrent delete not_found, and torn-generation check)
    • Post-lock directory state re-check removed from list_blobs: FAIL (1 check failed: concurrent container delete while waiting for lock)

Linux (local)

g++ -std=c++17 -O2 -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=undefined -pthread, no warnings. startup_gamesave_enumerate and startup_gamesave_persist pass under ASan and UBSan.

Additional Linux mutations of save_store.h, each rebuilt and restored:

Mutation Result
shared lock removed from list_blobs FAIL (busy checks)
suffixed and invalid names listed as blobs FAIL
blobs not sorted FAIL
output cleared before returning busy FAIL (output untouched)
plain files listed as containers FAIL
linked blobs followed FAIL
oversized blob skipped instead of too_large FAIL
containers not sorted FAIL
container names not checked FAIL

tests/docs_links_check.py and tests/bidi_controls_check.py pass, git diff --check origin/main...HEAD is clean. git merge-tree of this branch against current origin/main has no conflicts.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588376107 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1761). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:11:44Z. --- Part of the split of #1334 (enumeration, store only). No slot wiring: `runtime_proxy.cpp`, `save_read.inl` and the docs are untouched, so this does not overlap #1429 or the #1334 draft's slot code. The slot wiring (13, 14, 18, 20) is the next slice, after this one. ## Change `Store` in `src/startup_stubs/save_store.h` gets two read-only methods and two entry types: - `list_containers(std::vector<ContainerEntry>&)`: directories directly below the root, by name (byte order). Links and junctions, plain files, and names `valid_name` refuses (lock, staging and old suffixes in any case) are not listed. A root that does not exist yet lists as empty. - `list_blobs(container, std::vector<BlobEntry>&)`: name and size of the regular files of one container, by name. It is taken under the shared `lock_container`, the publication point `read_blobs` uses, so a commit from another process is listed whole or not at all. After acquiring the shared lock, `list_blobs` re-checks the container directory status so a concurrent `delete_container` or redirect swap while waiting for the lock reports `not_found` or `bad_name` rather than `io_error`. `not_found` for a missing container, `bad_name` for an invalid or redirected one, `busy` when the lock stays held for the whole timeout, `too_large` for a blob over `max_blob_bytes`. - `out` is replaced only on `ok`; on every other status it is left as the caller had it. No partial output. - No timestamps: that is a separate decision (the old #1334 commit used a process-local mutex, which a second process does not honour, and a clock conversion). ## Test `tests/startup_gamesave_enumerate.cpp` (plain C++17, synthetic data, registered next to `startup_gamesave_persist`). It covers: - exact names, sizes and order for two and five containers and three blobs, written out of order; a repeated listing gives the same answer; - not listed: `.x2w-part`, `.x2w-old`, `.x2w-lock` (also `.X2W-PART`), a name with `..`, a subdirectory, a plain file or lock directory in the root, a linked blob and a linked container (the link controls are skipped with a printed note where the platform refuses to create one); - `not_found`, `bad_name`, `io_error` (regular-file container / regular-file root), redirected root, empty root and empty container, `too_large` over the limit and the exact limit listed, all verifying `out` is untouched on non-`ok` status; - across processes (the test starts itself): - a child holds the exclusive lock, `list_blobs` returns `busy` after the timeout with the output untouched and another container still lists; after release the call succeeds; - a child holds the exclusive lock and deletes the container directory before releasing, `list_blobs` returns `not_found` (not `io_error`) with the output untouched; - a child publishes 300 two-blob generations through `commit` while this process lists in a loop: every listing has both blobs at one size, none fails, and it saw more than one generation. ## Results ### Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at `ccba9fcf9b0f858b9afc39130fa92d97024885d0` - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target d3d12_xs_shim startup_gameinput_history startup_gameinput_keys startup_gamesave_enumerate startup_gamesave_persist startup_gamesave_publish_locked startup_gamesave_publish_unlocked startup_stream_consumer startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xmem_shim -- -j 8`): `6.18s` (configure `1.71s`) - Test (`ctest --preset dev -R '^(startup_gameinput_history|startup_gameinput_keys|startup_gamesave_enumerate|startup_gamesave_persist|startup_gamesave_publish_locked|startup_gamesave_publish_unlocked|startup_storage_directory_batch|startup_stubs)$' --parallel 6 --no-tests=error --output-on-failure`): **8/8 passed** (`2.33s`: `startup_gamesave_enumerate` `1.70s`, `startup_gamesave_persist` `0.79s`, `startup_gamesave_publish_locked` `2.19s`, `startup_gamesave_publish_unlocked` `1.02s`, `startup_stubs` `0.70s`, `startup_storage_directory_batch` `0.20s`, `startup_gameinput_history` `0.05s`, `startup_gameinput_keys` `0.03s`) - **Release `/O2` (`--preset release`)**: - Build (same targets): `8.66s` (configure `1.71s`) - Test (same regex): **8/8 passed** (`2.26s`: `startup_gamesave_enumerate` `1.27s`, `startup_gamesave_persist` `0.65s`, `startup_gamesave_publish_locked` `2.13s`, `startup_gamesave_publish_unlocked` `0.99s`, `startup_stubs` `0.53s`, `startup_storage_directory_batch` `0.21s`, `startup_gameinput_history` `0.05s`, `startup_gameinput_keys` `0.03s`) - **Mutations verified on Windows Server 2025 (`startup_gamesave_enumerate`, Debug)**: - Shared lock removed from `list_blobs`: **FAIL** (5 checks failed: `busy`, `busy` output untouched, `busy` timeout, concurrent delete `not_found`, and torn-generation check) - Post-lock directory state re-check removed from `list_blobs`: **FAIL** (1 check failed: concurrent container delete while waiting for lock) ### Linux (local) `g++ -std=c++17 -O2 -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=undefined -pthread`, no warnings. `startup_gamesave_enumerate` and `startup_gamesave_persist` pass under ASan and UBSan. Additional Linux mutations of `save_store.h`, each rebuilt and restored: | Mutation | Result | |---|---| | shared lock removed from `list_blobs` | FAIL (busy checks) | | suffixed and invalid names listed as blobs | FAIL | | blobs not sorted | FAIL | | output cleared before returning `busy` | FAIL (output untouched) | | plain files listed as containers | FAIL | | linked blobs followed | FAIL | | oversized blob skipped instead of `too_large` | FAIL | | containers not sorted | FAIL | | container names not checked | FAIL | `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass, `git diff --check origin/main...HEAD` is clean. `git merge-tree` of this branch against current `origin/main` has no conflicts. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 19:01:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:55:42Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T18:58:48.022188Z ccba9fc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141348049 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1761#issuecomment-7141348049). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:55:42Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ccba9fcf9b0f858b9afc39130fa92d97024885d0","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T18:58:48.022188Z">2026-11-24T18:58:48.022188Z</relative-time> | `ccba9fc` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
upstream-sync closed this pull request 2026-11-24 20:00:30 +00:00
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!1754
No description provided.