startup: scope zlib stream cache to queued continuation entries #1228

Closed
lambirou wants to merge 1 commit from upstream-pr/1235 into main
lambirou commented 2026-11-24 04:48:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-24T04:48:38Z.


Change

This is stacked on #1214 at bb35f045. Review only the last commit, 0846d914; the earlier commits are #1214.

The queue-local stream cache still answered any aligned offset within the cached range when the file, compressed size and chunk size matched. A later independent request at a matching continuation offset could therefore receive the first stream's bytes.

  • Each queue entry now carries an id, and a cached stream records the exact ids of the following queued requests that form its continuation chain.
  • The cache lookup requires the current entry id to be in that chain. A later request with the same file, compressed size and offset gets a cache miss, decodes directly, and fails without touching its destination when the bytes are not a zlib stream.
  • The continuation scan skips status entries and stops at the first unrelated request, so a separate Submit cannot inherit a stale chain.
  • The source-built dstorage control now enqueues a valid chunked submission, then a separate Submit with a zlib-marked request at the exact matching offset. The request must fail and leave its 0xCC sentinel unchanged.

Verification

Windows 10.0.26300.10075, MSVC 19.44.35228.0, Ninja, Release.

ctest --preset release --no-tests=error -R '^startup_stubs$' -V
  • With this commit: startup_stubs passes 1/1.
  • Without the source change, the new control fails as expected: the independent request is answered with inflated (slice from stream cache) instead of failing.
  • git diff --check, tests/docs_links_check.py (16 files, 269 links) and tests/bidi_controls_check.py (1005 files) pass.

No game files, dumps or private logs were used. AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6574841636 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1235). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-24T04:48:38Z. --- ## Change This is stacked on #1214 at `bb35f045`. Review only the last commit, `0846d914`; the earlier commits are #1214. The queue-local stream cache still answered any aligned offset within the cached range when the file, compressed size and chunk size matched. A later independent request at a matching continuation offset could therefore receive the first stream's bytes. - Each queue entry now carries an id, and a cached stream records the exact ids of the following queued requests that form its continuation chain. - The cache lookup requires the current entry id to be in that chain. A later request with the same file, compressed size and offset gets a cache miss, decodes directly, and fails without touching its destination when the bytes are not a zlib stream. - The continuation scan skips status entries and stops at the first unrelated request, so a separate `Submit` cannot inherit a stale chain. - The source-built `dstorage` control now enqueues a valid chunked submission, then a separate `Submit` with a zlib-marked request at the exact matching offset. The request must fail and leave its `0xCC` sentinel unchanged. ## Verification Windows 10.0.26300.10075, MSVC 19.44.35228.0, Ninja, Release. ```powershell ctest --preset release --no-tests=error -R '^startup_stubs$' -V ``` - With this commit: `startup_stubs` passes 1/1. - Without the source change, the new control fails as expected: the independent request is answered with `inflated (slice from stream cache)` instead of failing. - `git diff --check`, `tests/docs_links_check.py` (16 files, 269 links) and `tests/bidi_controls_check.py` (1005 files) pass. No game files, dumps or private logs were used. AI-assisted (Codex).
upstream-sync closed this pull request 2026-11-24 06:47:09 +00:00
tedin7 commented 2026-11-24 06:47:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:58:37Z.

Review: COMMENTED


Reviewed commit 0846d914 on Linux (Windows build/tests were not run locally).

Stacking & diff audit

  • Stacked on #1214 at bb35f045 (note #1214 is currently open at 9570cec4).
  • src/startup_stubs/xcrdapi.cpp:
    • Entry gains a monotonic u64 id assigned in push() under work.mutex (++work.next_entry_id).
    • following_chunk_ids() scans work.submitted (after the current entry has already been popped in the worker loop) and work.waiting, skipping status_entry items and stopping at any non-continuation or mismatched request. Unsigned overflow is guarded both on initial offset + destination_size (expected < offset) and per step (expected > UINT64_MAX - destination_size).
    • CachedStream stores continuation_ids, and cache lookup in execute_request() requires entry_id to be present in continuation_ids in addition to matching source, compressed_size, and aligned offset > base_offset.
  • tests/startup_stub_consumer.cpp: expands the temp file to 16 MiB and adds a separate-Submit control at the matching continuation offset (chunk_dest_size) verifying non-zero status and untouched destination (0xCC).
  • docs/startup-runtime.md: documents stream-cache identity. 100% title-neutral.

Linux checks (0846d914)

  • docs_links_check.py: passed (16 Markdown files, 269 links).
  • bidi_controls_check.py: passed (1005 files).
  • form_coverage_check.py: passed.
  • git diff --check: clean.
  • startup_stub_check.py / startup_stub_consumer.cpp: Windows-only executable checks, not run locally.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033898857 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1235#pullrequestreview-6033898857). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:58:37Z. **Review:** COMMENTED --- Reviewed commit `0846d914` on Linux (Windows build/tests were not run locally). ### Stacking & diff audit - Stacked on `#1214` at `bb35f045` (note `#1214` is currently open at `9570cec4`). - `src/startup_stubs/xcrdapi.cpp`: - `Entry` gains a monotonic `u64 id` assigned in `push()` under `work.mutex` (`++work.next_entry_id`). - `following_chunk_ids()` scans `work.submitted` (after the current entry has already been popped in the worker loop) and `work.waiting`, skipping `status_entry` items and stopping at any non-continuation or mismatched request. Unsigned overflow is guarded both on initial `offset + destination_size` (`expected < offset`) and per step (`expected > UINT64_MAX - destination_size`). - `CachedStream` stores `continuation_ids`, and cache lookup in `execute_request()` requires `entry_id` to be present in `continuation_ids` in addition to matching `source`, `compressed_size`, and aligned `offset > base_offset`. - `tests/startup_stub_consumer.cpp`: expands the temp file to 16 MiB and adds a separate-`Submit` control at the matching continuation offset (`chunk_dest_size`) verifying non-zero status and untouched destination (`0xCC`). - `docs/startup-runtime.md`: documents stream-cache identity. 100% title-neutral. ### Linux checks (`0846d914`) - `docs_links_check.py`: passed (16 Markdown files, 269 links). - `bidi_controls_check.py`: passed (1005 files). - `form_coverage_check.py`: passed. - `git diff --check`: clean. - `startup_stub_check.py` / `startup_stub_consumer.cpp`: Windows-only executable checks, not run locally.
lambirou commented 2026-11-24 06:50:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-24T04:48:59Z.


@R0Y00 This is the remaining cache-identity case from #1214. It is stacked on #1214 at bb35f045; review only the last commit, 0846d914.

The queue cache now records the exact entry ids of the following queued requests that form the continuation chain, and a lookup requires the current entry id to be in that chain. The new source-built control does a valid chunked submission, then a separate Submit with a zlib-marked request at the exact matching offset; the request fails and its 0xCC sentinel stays unchanged. Against the previous head, the same control is answered by inflated (slice from stream cache).

Windows Release startup_stubs passes 1/1. Kept as a draft until #1214 lands. AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122364274 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1235#issuecomment-7122364274). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-24T04:48:59Z. --- @R0Y00 This is the remaining cache-identity case from #1214. It is stacked on #1214 at `bb35f045`; review only the last commit, `0846d914`. The queue cache now records the exact entry ids of the following queued requests that form the continuation chain, and a lookup requires the current entry id to be in that chain. The new source-built control does a valid chunked submission, then a separate `Submit` with a zlib-marked request at the exact matching offset; the request fails and its `0xCC` sentinel stays unchanged. Against the previous head, the same control is answered by `inflated (slice from stream cache)`. Windows Release `startup_stubs` passes 1/1. Kept as a draft until #1214 lands. AI-assisted (Codex).
lambirou commented 2026-11-24 06:50:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-24T04:51:15Z.


CI is green on 0846d914: Windows checks run 3038 passed (Windows build/tests, Linux Python checks, gfx1013 fixtures). The PR is ready for review, still stacked on #1214 at bb35f045; review only the last commit.

Local Release startup_stubs passes 1/1, and the separate-Submit control fails against the previous head, so the regression is covered. AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122397858 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1235#issuecomment-7122397858). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-24T04:51:15Z. --- CI is green on `0846d914`: `Windows checks` run 3038 passed (Windows build/tests, Linux Python checks, gfx1013 fixtures). The PR is ready for review, still stacked on #1214 at `bb35f045`; review only the last commit. Local Release `startup_stubs` passes 1/1, and the separate-`Submit` control fails against the previous head, so the regression is covered. AI-assisted (Codex).
tedin7 commented 2026-11-24 06:50:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:05:54Z.


Tested on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at commit 0846d914:

  • Debug (--preset dev):
    • Build: cmake --preset dev && cmake --build out/build/dev -j 6 --target startup_stub_consumer startup_stub_acphal startup_stub_chad startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs startup_stub_gameinput
    • Test: ctest --test-dir out/build/dev -R "^startup_stubs$" --output-on-failure -> 1/1 passed (0.49s, total 0.52s)
  • Release /O2 (--preset release):
    • Build: cmake --preset release && cmake --build out/build/release -j 6 --target startup_stub_consumer startup_stub_acphal startup_stub_chad startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs startup_stub_gameinput
    • Test: ctest --test-dir out/build/release -R "^startup_stubs$" --output-on-failure -> 1/1 passed (0.54s, total 0.57s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122620904 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1235#issuecomment-7122620904). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:05:54Z. --- Tested on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at commit `0846d914`: - **Debug (`--preset dev`)**: - Build: `cmake --preset dev && cmake --build out/build/dev -j 6 --target startup_stub_consumer startup_stub_acphal startup_stub_chad startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs startup_stub_gameinput` - Test: `ctest --test-dir out/build/dev -R "^startup_stubs$" --output-on-failure` -> **1/1 passed** (`0.49s`, total `0.52s`) - **Release `/O2` (`--preset release`)**: - Build: `cmake --preset release && cmake --build out/build/release -j 6 --target startup_stub_consumer startup_stub_acphal startup_stub_chad startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs startup_stub_gameinput` - Test: `ctest --test-dir out/build/release -R "^startup_stubs$" --output-on-failure` -> **1/1 passed** (`0.54s`, total `0.57s`)
R0Y00 commented 2026-11-24 06:50:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T05:22:21Z.


The continuation-entry ID approach from this PR is on main through #1214 (0fa43ad6), with the original contribution credited. The merged version also verifies the submission ID and has an event-gated two-batch control. Thanks for supplying the original separate-Submit regression and independent verification.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122885107 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1235#issuecomment-7122885107). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T05:22:21Z. --- The continuation-entry ID approach from this PR is on main through #1214 (0fa43ad6), with the original contribution credited. The merged version also verifies the submission ID and has an event-gated two-batch control. Thanks for supplying the original separate-Submit regression and independent verification.

Pull request closed

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!1228
No description provided.