startup: implement DirectStorage CancelRequestsWithTag #1862

Open
chunfeng11221 wants to merge 2 commits from upstream-pr/1869 into main
chunfeng11221 commented 2026-11-24 19:48:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chunfeng11221 on 2026-11-24T19:48:50Z.


Problem

In src/startup_stubs/xcrdapi.cpp, DirectStorage queue slot 7 (IDStorageQueue::CancelRequestsWithTag(UINT64 mask, UINT64 value)) is currently a no-op (#1843, slice 3).

Change

Implements CancelRequestsWithTag in src/startup_stubs/xcrdapi.cpp according to Microsoft's MIT-licensed Xbox GDK DirectStorage reference (Xbox-GDK-Samples/Samples/System/SimpleDirectStorageCombo/DirectStorageWin32/dstorage_win32.h, lines 238–331 and 552–562):

  • Reads UINT64 CancellationTag from DSTORAGE_REQUEST offset +0x38 and matches (tag & mask) == value (tag_matches).
  • Pre-Submit (work->waiting): compacts matching Entry::request entries out in place without heap allocation, preserving the order of non-matching requests, status entries, and fence signals.
  • Post-Submit (work->submitted) & OOM/deferred lists (work->failing, self->unrecorded_head, work->deferred_head): marks matching requests cancelled = true in place (releasing captured page tokens) so submitted_total/finished_total drain invariants and deferred-completion cutoffs remain intact.
  • Execution & failure accounting: run_entry, fail_unrecorded, fail_waiting, and complete_deferred skip cancelled requests without performing I/O, touching destinations, incrementing requests_failed, or setting self->pending = E_FAIL. following_chunk_ids stops at a cancelled entry rather than extending a chunked stream cache across it.
  • Acquires setup_mutex() and work->mutex sequentially (never nested in reverse order), matching submit()'s locking discipline.
  • Note: execute_request (xcrdapi.cpp:519) still reads +0x38 as an inflate buffer-sizing hint; left untouched here to keep this PR scoped strictly to slice 3 and conflict-free with slices 1 and 2 (#1847).
  • Updates docs/startup-runtime.md and registers startup_storage_cancel plus startup_storage_cancel_control (WILL_FAIL TRUE) in CMakeLists.txt.

Verification

Tested on Windows 11 x64 (MSVC 19.44.35228, Windows SDK 10.0.26100.0, base commit 939e514), synthetic file and memory fixtures only (no game files):

  • startup_storage_cancel exercises 7 scenarios against XCRDAPI.dll:
    1. Fresh-queue cancel no-op + exact tag match (~0ull) before Submit (file and memory sources)
    2. Partial 64-bit mask group cancellation (0xFFFFFFFF00000000 / 0x0000000200000000)
    3. Unmasked value bit adversarial check (mask=0x0F, value=0x1F cancels nothing)
    4. Wildcard cancel-all (mask=0, value=0) including an EOF-failing request — destination stays poisoned, status completes S_OK, and log contains no read failed
    5. Temporal boundary — a request with the same tag enqueued after CancelRequestsWithTag still executes
    6. Post-Submit concurrent cancellation — blocks the worker deterministically on a gate EnqueueSignal fence so requests sit in work->submitted, cancels a matching EOF-failing request live, releases the gate, and confirms clean drain, untouched destination, sibling completion, and S_OK
    7. Mixed batch — cancelled valid request alongside an uncancelled EOF-failing request preserves the cancelled destination while still surfacing E_FAIL on status
  • dev preset: ctest --preset dev --no-tests=error -R "^startup_(storage_(alloc_failure|refusal_order|cancel|failure_counts|worker_start)|dstorage_destination)" — 8/8 passed (startup_storage_cancel, startup_storage_cancel_control, startup_storage_alloc_failure, startup_storage_refusal_order, startup_storage_failure_counts, startup_storage_failure_counts_one_bucket_control, startup_dstorage_destination, startup_storage_worker_start).
  • release preset: ctest --preset release --no-tests=error -R "^startup_storage_cancel(_control)?$" — 2/2 passed (0.03 s).
  • tests/docs_links_check.py (18 Markdown files, 370 links) and tests/bidi_controls_check.py (1323 tracked files) — both passed.

Fail-first mutation controls

  • Built-in startup_storage_cancel_control (--control-expect-uncancelled, WILL_FAIL TRUE): fails as expected because the cancelled request did not write its destination.
  • Source mutation A (short-circuit queue_cancel to no-op): startup_storage_cancel fails across cases 1, 2, 4, 5, 6, and 7.
  • Source mutation B (mutate tag_matches to (tag & mask) == (value & mask)): startup_storage_cancel fails on case 3 (unmasked bit did not cancel).

Scope / What this does not establish

  • Does not change initial status-array state (slice 1, #1847) or RetrieveErrorRecord / GetErrorEvent (slice 2).
  • Requests already popped by the worker and actively executing in execute_request are allowed to finish, matching DirectStorage's "attempts to cancel" contract.

Refs #1843.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5479197278 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869). Originally posted by [chunfeng11221](https://github.com/chunfeng11221) on 2026-11-24T19:48:50Z. --- ## Problem In `src/startup_stubs/xcrdapi.cpp`, DirectStorage queue slot 7 (`IDStorageQueue::CancelRequestsWithTag(UINT64 mask, UINT64 value)`) is currently a no-op (#1843, slice 3). ## Change Implements `CancelRequestsWithTag` in `src/startup_stubs/xcrdapi.cpp` according to Microsoft's MIT-licensed Xbox GDK DirectStorage reference (`Xbox-GDK-Samples/Samples/System/SimpleDirectStorageCombo/DirectStorageWin32/dstorage_win32.h`, lines 238–331 and 552–562): - Reads `UINT64 CancellationTag` from `DSTORAGE_REQUEST` offset `+0x38` and matches `(tag & mask) == value` (`tag_matches`). - **Pre-`Submit` (`work->waiting`)**: compacts matching `Entry::request` entries out in place without heap allocation, preserving the order of non-matching requests, status entries, and fence signals. - **Post-`Submit` (`work->submitted`) & OOM/deferred lists (`work->failing`, `self->unrecorded_head`, `work->deferred_head`)**: marks matching requests `cancelled = true` in place (releasing captured page tokens) so `submitted_total`/`finished_total` drain invariants and deferred-completion cutoffs remain intact. - **Execution & failure accounting**: `run_entry`, `fail_unrecorded`, `fail_waiting`, and `complete_deferred` skip cancelled requests without performing I/O, touching destinations, incrementing `requests_failed`, or setting `self->pending = E_FAIL`. `following_chunk_ids` stops at a cancelled entry rather than extending a chunked stream cache across it. - Acquires `setup_mutex()` and `work->mutex` sequentially (never nested in reverse order), matching `submit()`'s locking discipline. - Note: `execute_request` (`xcrdapi.cpp:519`) still reads `+0x38` as an inflate buffer-sizing hint; left untouched here to keep this PR scoped strictly to slice 3 and conflict-free with slices 1 and 2 (#1847). - Updates `docs/startup-runtime.md` and registers `startup_storage_cancel` plus `startup_storage_cancel_control` (`WILL_FAIL TRUE`) in `CMakeLists.txt`. ## Verification Tested on Windows 11 x64 (`MSVC 19.44.35228`, Windows SDK `10.0.26100.0`, base commit `939e514`), synthetic file and memory fixtures only (no game files): - `startup_storage_cancel` exercises 7 scenarios against `XCRDAPI.dll`: 1. Fresh-queue cancel no-op + exact tag match (`~0ull`) before `Submit` (file and memory sources) 2. Partial 64-bit mask group cancellation (`0xFFFFFFFF00000000` / `0x0000000200000000`) 3. Unmasked value bit adversarial check (`mask=0x0F, value=0x1F` cancels nothing) 4. Wildcard cancel-all (`mask=0, value=0`) including an EOF-failing request — destination stays poisoned, status completes `S_OK`, and log contains no `read failed` 5. Temporal boundary — a request with the same tag enqueued *after* `CancelRequestsWithTag` still executes 6. Post-`Submit` concurrent cancellation — blocks the worker deterministically on a gate `EnqueueSignal` fence so requests sit in `work->submitted`, cancels a matching EOF-failing request live, releases the gate, and confirms clean drain, untouched destination, sibling completion, and `S_OK` 7. Mixed batch — cancelled valid request alongside an uncancelled EOF-failing request preserves the cancelled destination while still surfacing `E_FAIL` on status - `dev` preset: `ctest --preset dev --no-tests=error -R "^startup_(storage_(alloc_failure|refusal_order|cancel|failure_counts|worker_start)|dstorage_destination)"` — 8/8 passed (`startup_storage_cancel`, `startup_storage_cancel_control`, `startup_storage_alloc_failure`, `startup_storage_refusal_order`, `startup_storage_failure_counts`, `startup_storage_failure_counts_one_bucket_control`, `startup_dstorage_destination`, `startup_storage_worker_start`). - `release` preset: `ctest --preset release --no-tests=error -R "^startup_storage_cancel(_control)?$"` — 2/2 passed (0.03 s). - `tests/docs_links_check.py` (18 Markdown files, 370 links) and `tests/bidi_controls_check.py` (1323 tracked files) — both passed. ### Fail-first mutation controls - Built-in `startup_storage_cancel_control` (`--control-expect-uncancelled`, `WILL_FAIL TRUE`): fails as expected because the cancelled request did not write its destination. - Source mutation A (short-circuit `queue_cancel` to no-op): `startup_storage_cancel` fails across cases 1, 2, 4, 5, 6, and 7. - Source mutation B (mutate `tag_matches` to `(tag & mask) == (value & mask)`): `startup_storage_cancel` fails on case 3 (`unmasked bit did not cancel`). ## Scope / What this does not establish - Does not change initial status-array state (slice 1, #1847) or `RetrieveErrorRecord` / `GetErrorEvent` (slice 2). - Requests already popped by the worker and actively executing in `execute_request` are allowed to finish, matching DirectStorage's "attempts to cancel" contract. Refs #1843. AI-assisted.
tedin7 commented 2026-11-24 19:55:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:55:47Z.

Review: COMMENTED


Review of head ece618ec61aee55120c64cd0f08dcb0b1e94b435 (one commit on origin/main; git merge-tree --write-tree origin/main HEAD merges without conflicts).

Verdict: no P1, no P2. Three P3 notes. The test and the stub are Windows-only (the stub uses MSVC __try/__except), so I could not run them here; what I checked, I checked by reading and by a small harness described below.

Public contract. I compared the change with Microsoft's MIT-licensed Win32 wrapper in Xbox-GDK-Samples (DirectStorageWin32/dstorage_win32.h and DirectStorageWin32WrapperQueue.cpp, read from GitHub):

  • The formula there is (CancellationTag & mask) == value, with no masking of value. tag_matches is exactly that, so a value with bits outside mask matches nothing, and case 3 of the test pins it.
  • The header says a cancelled request "may or may not complete its original read request" and is "not counted as a failure in either IDStorageStatusX or DSTORAGE_ERROR_RECORD". The PR skips the I/O, leaves the destination untouched, does not touch requests_failed and does not fail later status entries.
  • The reference only cancels pending and submitted requests (not ones the hardware is already working on). Here an entry the worker has already popped (entry = std::move(work.submitted.front()); pop_front() under work.mutex) is out of submitted, so it cannot be marked: the same boundary.
  • Offset: in that header Options is at 0, the destination union at 0x08 to 0x18, DestinationSize at 0x18, the source union at 0x20 to 0x30, SourceSize at 0x30, IntermediateSize at 0x34, CancellationTag at 0x38 and Name at 0x40, so 0x48 in all, which is Entry::bytes. The read at +0x38 stays inside the array.

Locking and races

  • queue_cancel takes setup_mutex to read self->work and scan the unrecorded list, releases it, then takes work->mutex for waiting, submitted, failing and the deferred list. It never holds both, so it cannot invert the order Submit uses (work->mutex then setup_mutex).
  • A node that Submit moves from the unrecorded list to the deferred list is never missed. Submit holds work->mutex across the detach and the append; if cancel scans the unrecorded list after the detach, its second step blocks on work->mutex until the node is in the deferred list.
  • The marking in submitted and failing happens under work->mutex, the same lock under which the worker moves an entry out, so no entry is read by the worker while it is being edited. tokens.reset() on a marked entry is therefore safe.
  • Skipped entries still count: run_entry returns early, the worker goes on to ++finished_total, so submitted_total/finished_total and the cutoffs of deferred completions are unchanged. following_chunk_ids stops at a cancelled entry, so no read-ahead is started for it. The four fail_unstarted call sites skip a cancelled request.
  • Unrecorded is only built in defer_unrecorded, so tag and cancelled are always set from the entry.

Commands run locally on Linux

  • python3 -B tests/docs_links_check.py (18 files, 370 links), python3 -B tests/bidi_controls_check.py (1324 files): pass. git diff --check origin/main...HEAD: clean.
  • x86_64-w64-mingw32-g++ compiles tests/startup_storage_cancel.cpp; the stub itself does not build with it (MSVC-only SEH in local_log.h), and there is no working Wine here, so the DLL and the test were not run.
  • Harness outside the repository: the compaction loop copied byte for byte from queue_cancel (std::deque<Entry>, in-place move, pop_back) with the PR's tag_matches and request_cancellation_tag, 20,000 random queues of 0 to 11 mixed request/status/signal entries and random masks and values, compared with a plain model, built with ASan and UBSan: 0 mismatches. The mutant with ++write replaced by write += 0 gives 18,320 mismatches in the same run.

Findings

  1. P3, not exercised: the failing, deferred and unrecorded branches of queue_cancel (and the three fail_unstarted skips that go with them) only run when an allocation fails; the test's cases 1 to 7 cover waiting and submitted. The existing startup_storage_alloc_failure fixture shows an injected failure is possible, so one case that cancels an entry that was deferred by a failed allocation would pin them.
  2. P3, capacity: a cancelled request that is still waiting is removed at once, so the queue's "full" test (waiting.size() >= capacity) sees room that the reference queue does not give back until the entry is released. It cannot lose a request; it can only delay an automatic Submit by one.
  3. P3, doc: the new paragraph says "Already-submitted requests waiting for the worker (and any OOM-deferred requests) are marked cancelled in place". It does not say that a request the worker has already started cannot be cancelled; the reference has the same limit and it is worth one sentence.

Not run: the Windows build, startup_storage_cancel and its control, and ASan/TSan on the stub itself.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046349391 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#pullrequestreview-6046349391). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:55:47Z. **Review:** COMMENTED --- Review of head `ece618ec61aee55120c64cd0f08dcb0b1e94b435` (one commit on `origin/main`; `git merge-tree --write-tree origin/main HEAD` merges without conflicts). **Verdict: no P1, no P2. Three P3 notes.** The test and the stub are Windows-only (the stub uses MSVC `__try`/`__except`), so I could not run them here; what I checked, I checked by reading and by a small harness described below. **Public contract.** I compared the change with Microsoft's MIT-licensed Win32 wrapper in Xbox-GDK-Samples (`DirectStorageWin32/dstorage_win32.h` and `DirectStorageWin32WrapperQueue.cpp`, read from GitHub): - The formula there is `(CancellationTag & mask) == value`, with no masking of `value`. `tag_matches` is exactly that, so a `value` with bits outside `mask` matches nothing, and case 3 of the test pins it. - The header says a cancelled request "may or may not complete its original read request" and is "not counted as a failure in either IDStorageStatusX or DSTORAGE_ERROR_RECORD". The PR skips the I/O, leaves the destination untouched, does not touch `requests_failed` and does not fail later status entries. - The reference only cancels pending and submitted requests (not ones the hardware is already working on). Here an entry the worker has already popped (`entry = std::move(work.submitted.front()); pop_front()` under `work.mutex`) is out of `submitted`, so it cannot be marked: the same boundary. - Offset: in that header `Options` is at 0, the destination union at 0x08 to 0x18, `DestinationSize` at 0x18, the source union at 0x20 to 0x30, `SourceSize` at 0x30, `IntermediateSize` at 0x34, `CancellationTag` at 0x38 and `Name` at 0x40, so 0x48 in all, which is `Entry::bytes`. The read at +0x38 stays inside the array. **Locking and races** - `queue_cancel` takes `setup_mutex` to read `self->work` and scan the unrecorded list, releases it, then takes `work->mutex` for `waiting`, `submitted`, `failing` and the deferred list. It never holds both, so it cannot invert the order Submit uses (`work->mutex` then `setup_mutex`). - A node that Submit moves from the unrecorded list to the deferred list is never missed. Submit holds `work->mutex` across the detach and the append; if cancel scans the unrecorded list after the detach, its second step blocks on `work->mutex` until the node is in the deferred list. - The marking in `submitted` and `failing` happens under `work->mutex`, the same lock under which the worker moves an entry out, so no entry is read by the worker while it is being edited. `tokens.reset()` on a marked entry is therefore safe. - Skipped entries still count: `run_entry` returns early, the worker goes on to `++finished_total`, so `submitted_total`/`finished_total` and the cutoffs of deferred completions are unchanged. `following_chunk_ids` stops at a cancelled entry, so no read-ahead is started for it. The four `fail_unstarted` call sites skip a cancelled request. - `Unrecorded` is only built in `defer_unrecorded`, so `tag` and `cancelled` are always set from the entry. **Commands run locally on Linux** - `python3 -B tests/docs_links_check.py` (18 files, 370 links), `python3 -B tests/bidi_controls_check.py` (1324 files): pass. `git diff --check origin/main...HEAD`: clean. - `x86_64-w64-mingw32-g++` compiles `tests/startup_storage_cancel.cpp`; the stub itself does not build with it (MSVC-only SEH in `local_log.h`), and there is no working Wine here, so the DLL and the test were not run. - Harness outside the repository: the compaction loop copied byte for byte from `queue_cancel` (`std::deque<Entry>`, in-place move, `pop_back`) with the PR's `tag_matches` and `request_cancellation_tag`, 20,000 random queues of 0 to 11 mixed request/status/signal entries and random masks and values, compared with a plain model, built with ASan and UBSan: 0 mismatches. The mutant with `++write` replaced by `write += 0` gives 18,320 mismatches in the same run. **Findings** 1. **P3, not exercised:** the `failing`, deferred and unrecorded branches of `queue_cancel` (and the three `fail_unstarted` skips that go with them) only run when an allocation fails; the test's cases 1 to 7 cover `waiting` and `submitted`. The existing `startup_storage_alloc_failure` fixture shows an injected failure is possible, so one case that cancels an entry that was deferred by a failed allocation would pin them. 2. **P3, capacity:** a cancelled request that is still waiting is removed at once, so the queue's "full" test (`waiting.size() >= capacity`) sees room that the reference queue does not give back until the entry is released. It cannot lose a request; it can only delay an automatic Submit by one. 3. **P3, doc:** the new paragraph says "Already-submitted requests waiting for the worker (and any OOM-deferred requests) are marked cancelled in place". It does not say that a request the worker has already started cannot be cancelled; the reference has the same limit and it is worth one sentence. **Not run:** the Windows build, `startup_storage_cancel` and its control, and ASan/TSan on the stub itself. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-24 20:05:21 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


The cancellation match and queue-order controls look useful. There is one compatibility blocker before we advertise arbitrary request tags. This PR reads +0x38 as CancellationTag, while execute_request also reads its low word as an uncompressed size and passes it to output.resize. The public Xbox request layout identifies +0x34 as IntermediateSize for combined zlib and BCPack and +0x38 as the opaque tag. With the current decoder, the low word of the tag changes the inflate allocation for an uncancelled request. The raw cancellation fixtures cannot distinguish that.

Please make the ABI and decode sizing consistent before enabling this on main. A source-built accepted case should submit the same zlib payload with two different nonzero tags and verify identical completion, bytes, and bounded decode sizing; the cancellation counterpart should leave the destination unchanged and preserve status/fence ordering. Keep existing chunked and capacity refusals. Coordinate shared layout declarations with #1873.

Microsoft Xbox request definition.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046494174 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#pullrequestreview-6046494174). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T20:05:21Z. **Review:** CHANGES_REQUESTED --- The cancellation match and queue-order controls look useful. There is one compatibility blocker before we advertise arbitrary request tags. This PR reads +0x38 as CancellationTag, while execute_request also reads its low word as an uncompressed size and passes it to output.resize. The public Xbox request layout identifies +0x34 as IntermediateSize for combined zlib and BCPack and +0x38 as the opaque tag. With the current decoder, the low word of the tag changes the inflate allocation for an uncancelled request. The raw cancellation fixtures cannot distinguish that. Please make the ABI and decode sizing consistent before enabling this on main. A source-built accepted case should submit the same zlib payload with two different nonzero tags and verify identical completion, bytes, and bounded decode sizing; the cancellation counterpart should leave the destination unchanged and preserve status/fence ordering. Keep existing chunked and capacity refusals. Coordinate shared layout declarations with #1873. [Microsoft Xbox request definition](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/dstorage/structs/dstorage_request?view=gdk-2604).
ChazY11 commented 2026-11-24 21:01:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T20:18:03Z.


Built it and broke three parts of the cancellation

At the PR head, Windows 11 build 26300.9974, MSVC 19.44:

cmake --preset dev
cmake --build --preset dev --target startup_stub_xcrdapi
ctest --preset dev --no-tests=error -R '^startup_storage_cancel$'
100% tests passed, 0 tests failed out of 1

Three mutations to src/startup_stubs/xcrdapi.cpp, each rebuilt into XCRDAPI.dll (the test does LoadLibraryA(argv[1]))
with the DLL timestamp verified to change, then reverted:

mutation result
tag_matches: return (tag & mask) == value; → return true; caught
the matched entry no longer sets cancelled caught
cancellation_tag_offset 0x38 → 0x30 caught

The third is the one I care about most: the offset is the only thing tying this to the console DSTORAGE_REQUEST layout, and
0x30 still reads some bytes, so a fixture that only checked "the count went down" would pass. It does not.

Measurement note, same trap as in #1874: my first run rebuilt startup_storage_cancel.exe and reported "not rebuilt" for
all three, because the exe is only the harness. Rebuilding the DLL is what makes the mutants visible; a "survivor" that never
rebuilt is not a survivor.

What the fixture covers, from reading it

  • Pre-Submit compaction in place, order preserved for the entries that stay.
  • A --control-expect-uncancelled mode, which is the right shape for the negative control (mask/value that match nothing).
  • Tag read from the request bytes rather than from a stub-side copy, so the offset mutation above is reachable.

Two questions

  1. Post-Submit behaviour. The description covers the pre-Submit path in detail; for a request already handed to a
    worker the reference marks it and lets it complete. Does the fixture exercise that ordering (cancel after Submit, expect
    the read to finish and the status to be "cancelled" rather than "failed")? If it does, ignore this — I could not tell from
    the names.
  2. mask = 0. With tag_matches as written, mask = 0, value = 0 matches every request. That is what the reference
    does, but it is also the kind of call a caller makes by accident. A one-line note in the doc row ("mask 0 cancels
    everything") would save someone an afternoon.

Verdict

Reviewed. The three parts that make the feature work are each pinned by the new fixture. No objections to the change.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143329537 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#issuecomment-7143329537). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T20:18:03Z. --- ## Built it and broke three parts of the cancellation At the PR head, Windows 11 build 26300.9974, MSVC 19.44: ```powershell cmake --preset dev cmake --build --preset dev --target startup_stub_xcrdapi ctest --preset dev --no-tests=error -R '^startup_storage_cancel$' 100% tests passed, 0 tests failed out of 1 ``` Three mutations to `src/startup_stubs/xcrdapi.cpp`, each rebuilt into **XCRDAPI.dll** (the test does `LoadLibraryA(argv[1])`) with the DLL timestamp verified to change, then reverted: | mutation | result | |---|---| | `tag_matches`: `return (tag & mask) == value;` → `return true;` | **caught** | | the matched entry no longer sets `cancelled` | **caught** | | `cancellation_tag_offset` `0x38` → `0x30` | **caught** | The third is the one I care about most: the offset is the only thing tying this to the console `DSTORAGE_REQUEST` layout, and `0x30` still reads *some* bytes, so a fixture that only checked "the count went down" would pass. It does not. **Measurement note**, same trap as in #1874: my first run rebuilt `startup_storage_cancel.exe` and reported "not rebuilt" for all three, because the exe is only the harness. Rebuilding the DLL is what makes the mutants visible; a "survivor" that never rebuilt is not a survivor. ## What the fixture covers, from reading it - Pre-`Submit` compaction in place, order preserved for the entries that stay. - A `--control-expect-uncancelled` mode, which is the right shape for the negative control (`mask`/`value` that match nothing). - Tag read from the request bytes rather than from a stub-side copy, so the offset mutation above is reachable. ## Two questions 1. **Post-`Submit` behaviour.** The description covers the pre-`Submit` path in detail; for a request already handed to a worker the reference marks it and lets it complete. Does the fixture exercise that ordering (cancel after `Submit`, expect the read to finish and the status to be "cancelled" rather than "failed")? If it does, ignore this — I could not tell from the names. 2. **`mask = 0`.** With `tag_matches` as written, `mask = 0, value = 0` matches **every** request. That is what the reference does, but it is also the kind of call a caller makes by accident. A one-line note in the doc row ("mask 0 cancels everything") would save someone an afternoon. ## Verdict Reviewed. The three parts that make the feature work are each pinned by the new fixture. No objections to the change. ## Notes - AI-assisted review.
tedin7 commented 2026-11-25 13:01:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:38Z.


@chunfeng11221 could you rebase this branch onto current main and force-push?

GitHub reports head ece618ec as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (cf97bee1):

  • src/startup_stubs/xcrdapi.cpp

Commands run locally:

git fetch origin main pull/1869/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 1869 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163002822 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#issuecomment-7163002822). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:53:38Z. --- @chunfeng11221 could you rebase this branch onto current `main` and force-push? GitHub reports head `ece618ec` as conflicting with `main`, so it cannot be merged as is. Files that conflict with current `main` (`cf97bee1`): - `src/startup_stubs/xcrdapi.cpp` Commands run locally: ``` git fetch origin main pull/1869/head git merge-tree --write-tree --name-only origin/main FETCH_HEAD gh pr view 1869 --json mergeable # CONFLICTING ``` Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-27 09:36:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T09:36:44Z.


This PR now conflicts with main. Conflicting files:

  • docs/startup-runtime.md
  • src/startup_stubs/xcrdapi.cpp

Could you merge main into your branch (a merge commit, no force push needed) and resolve these? Thank you.

AI-assisted; commands listed were executed locally. (git merge-tree origin/main <head>)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7214885610 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#issuecomment-7214885610). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T09:36:44Z. --- This PR now conflicts with `main`. Conflicting files: - `docs/startup-runtime.md` - `src/startup_stubs/xcrdapi.cpp` Could you merge `main` into your branch (a merge commit, no force push needed) and resolve these? Thank you. AI-assisted; commands listed were executed locally. (`git merge-tree origin/main <head>`)
chunfeng11221 commented 2026-11-27 09:54:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chunfeng11221 on 2026-11-27T09:54:45Z.


@tedin7 @R0Y00 @ChazY11 Thank you all for the reviews and checks! Merged main (8a901eb2) via a regular merge commit (c0d2977c, no force-push) and resolved all review items:

Merge conflict resolution (src/startup_stubs/xcrdapi.cpp, docs/startup-runtime.md)

  • Preserved #2788 object refcounting across all cancellation paths (queue_cancel calls release_entry/release_unrecorded on cancelled waiting, submitted, failing, unrecorded, and deferred requests; the fail_unstarted skip paths unconditionally release retained references).
  • Preserved #1873 error notification/retrieval (DSTORAGE_ERROR_RECORD and GetErrorEvent are untouched by cancelled requests), x2w_local::first_calls, and main's startup_memory_srv_volume and CopyTextureRegion doc sections.

Request tag & inflate-sizing consistency (@R0Y00)

  • main (f3f34f3d) keeps +0x34 (IntermediateSize) separate from opaque +0x38 (CancellationTag) and never sizes the inflate buffer from +0x38.
  • Coordinated shared layout declarations with #1873 (src/startup_stubs/dstorage_error_record.h): request_cancellation_tag reads offsetof(StorageRequest, cancellation_tag) on sizeof(StorageRequest) bytes (Unrecorded reuses bytes[sizeof(StorageRequest)]), and tests/startup_storage_cancel.cpp constructs x2w_startup::StorageRequest and checks x2w_startup::StorageErrorRecord directly.
  • Added Case 8 in tests/startup_storage_cancel.cpp: submits a source-built zlib payload (stored_zlib) with two distinct nonzero tags (0x1111111100000001 and 0x222222227FFFFFFF, ~2 GiB low word) verifying identical S_OK completion, identical decoded bytes, zero error record, and bounded process commit growth (< 64 MiB), alongside its cancellation counterpart verifying untouched destination, surviving sibling, status/fence ordering, and no error record/event.
  • Updated Case 7 for HRESULT_FROM_WIN32(ERROR_HANDLE_EOF) and RetrieveErrorRecord / GetErrorEvent verification, and added Case 9 pinning #2788 file refcount release across pre-Submit (waiting) and post-Submit (submitted) cancellations.

Reviewer notes (@tedin7, @ChazY11)

  • @tedin7: Added cancelled_deferred_entries in tests/startup_storage_worker_start.cpp exercising unrecorded_head -> fail_unrecorded, unrecorded_head -> deferred_head -> complete_deferred, and live work->deferred_head cancellation behind a held prefix fence; added the already-dequeued worker boundary note to docs/startup-runtime.md.
  • @ChazY11: Thanks for running the 3-mutant checks! Post-Submit cancellation ordering is covered by Case 6 in tests/startup_storage_cancel.cpp (holds the worker on a GateFence after Submit, cancels an EOF-failing request live in work->submitted, and verifies clean drain, untouched destination, surviving sibling, S_OK, zero error record, and unsignaled GetErrorEvent). Added a note in docs/startup-runtime.md explicitly calling out that mask = 0, value = 0 matches and cancels every queued request.

Local verification (Windows 11 x64, MSVC 19.44)

  • Dev: ctest --preset dev --no-tests=error -R "^startup_(storage_|dstorage_|xcrdapi_)" — 21/21 passed (including startup_storage_cancel, startup_storage_cancel_control, startup_storage_worker_start, startup_storage_alloc_failure, startup_storage_refusal_order, startup_storage_failure_counts, startup_xcrdapi_lifetime); tests/startup_stub_check.py PASS (including dstorage error record and status-array initial state).
  • Release: ctest --preset release --no-tests=error -R "^startup_(storage_(cancel|worker_start|alloc_failure|refusal_order|failure_counts)|dstorage_destination|xcrdapi_lifetime)" — 10/10 passed; tests/startup_stub_check.py PASS.
  • Repo checks: tests/docs_links_check.py (40 Markdown files, 555 links) and tests/bidi_controls_check.py (2094 files) both passed.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7215245515 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#issuecomment-7215245515). Originally posted by [chunfeng11221](https://github.com/chunfeng11221) on 2026-11-27T09:54:45Z. --- @tedin7 @R0Y00 @ChazY11 Thank you all for the reviews and checks! Merged `main` (`8a901eb2`) via a regular merge commit (`c0d2977c`, no force-push) and resolved all review items: ### Merge conflict resolution (`src/startup_stubs/xcrdapi.cpp`, `docs/startup-runtime.md`) - Preserved `#2788` object refcounting across all cancellation paths (`queue_cancel` calls `release_entry`/`release_unrecorded` on cancelled `waiting`, `submitted`, `failing`, `unrecorded`, and `deferred` requests; the `fail_unstarted` skip paths unconditionally release retained references). - Preserved `#1873` error notification/retrieval (`DSTORAGE_ERROR_RECORD` and `GetErrorEvent` are untouched by cancelled requests), `x2w_local::first_calls`, and `main`'s `startup_memory_srv_volume` and `CopyTextureRegion` doc sections. ### Request tag & inflate-sizing consistency (@R0Y00) - `main` (`f3f34f3d`) keeps `+0x34` (`IntermediateSize`) separate from opaque `+0x38` (`CancellationTag`) and never sizes the inflate buffer from `+0x38`. - Coordinated shared layout declarations with `#1873` (`src/startup_stubs/dstorage_error_record.h`): `request_cancellation_tag` reads `offsetof(StorageRequest, cancellation_tag)` on `sizeof(StorageRequest)` bytes (`Unrecorded` reuses `bytes[sizeof(StorageRequest)]`), and `tests/startup_storage_cancel.cpp` constructs `x2w_startup::StorageRequest` and checks `x2w_startup::StorageErrorRecord` directly. - Added **Case 8** in `tests/startup_storage_cancel.cpp`: submits a source-built zlib payload (`stored_zlib`) with two distinct nonzero tags (`0x1111111100000001` and `0x222222227FFFFFFF`, ~2 GiB low word) verifying identical `S_OK` completion, identical decoded bytes, zero error record, and bounded process commit growth (`< 64 MiB`), alongside its cancellation counterpart verifying untouched destination, surviving sibling, status/fence ordering, and no error record/event. - Updated **Case 7** for `HRESULT_FROM_WIN32(ERROR_HANDLE_EOF)` and `RetrieveErrorRecord` / `GetErrorEvent` verification, and added **Case 9** pinning `#2788` file refcount release across pre-Submit (`waiting`) and post-Submit (`submitted`) cancellations. ### Reviewer notes (@tedin7, @ChazY11) - @tedin7: Added `cancelled_deferred_entries` in `tests/startup_storage_worker_start.cpp` exercising `unrecorded_head` -> `fail_unrecorded`, `unrecorded_head` -> `deferred_head` -> `complete_deferred`, and live `work->deferred_head` cancellation behind a held prefix fence; added the already-dequeued worker boundary note to `docs/startup-runtime.md`. - @ChazY11: Thanks for running the 3-mutant checks! Post-`Submit` cancellation ordering is covered by **Case 6** in `tests/startup_storage_cancel.cpp` (holds the worker on a `GateFence` after `Submit`, cancels an EOF-failing request live in `work->submitted`, and verifies clean drain, untouched destination, surviving sibling, `S_OK`, zero error record, and unsignaled `GetErrorEvent`). Added a note in `docs/startup-runtime.md` explicitly calling out that `mask = 0, value = 0` matches and cancels every queued request. ### Local verification (Windows 11 x64, MSVC 19.44) - **Dev**: `ctest --preset dev --no-tests=error -R "^startup_(storage_|dstorage_|xcrdapi_)"` — **21/21 passed** (including `startup_storage_cancel`, `startup_storage_cancel_control`, `startup_storage_worker_start`, `startup_storage_alloc_failure`, `startup_storage_refusal_order`, `startup_storage_failure_counts`, `startup_xcrdapi_lifetime`); `tests/startup_stub_check.py` **PASS** (including `dstorage error record` and `status-array initial state`). - **Release**: `ctest --preset release --no-tests=error -R "^startup_(storage_(cancel|worker_start|alloc_failure|refusal_order|failure_counts)|dstorage_destination|xcrdapi_lifetime)"` — **10/10 passed**; `tests/startup_stub_check.py` **PASS**. - **Repo checks**: `tests/docs_links_check.py` (40 Markdown files, 555 links) and `tests/bidi_controls_check.py` (2094 files) both passed.
pigalot commented 2026-11-27 22:08:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:08:13Z.

Review: APPROVED


I reviewed c0d2977c merged over current main 6cc46a3c. The merge is clean and git diff --cached --check is clean.

R0Y00's ABI blocker on ece618ec.

  • Decode sizing: on current main, execute_request sizes the inflate buffer from +0x34 (IntermediateSize), and only when BCPack follows zlib. A zlib-only request inflates to DestinationSize. Nothing reads a size from +0x38.
  • Tag reads: this PR reads the tag through offsetof(StorageRequest, cancellation_tag). dstorage_error_record.h pins that offset at 0x38 with a static_assert, so the tag and the decode size no longer overlap.
  • Requested fixture: Case 8 submits the same source-built zlib payload under tags 0x1111111100000001 and 0x222222227FFFFFFF. It checks matching completion and bytes, no error record and bounded commit growth.

What I traced.

  • Lock order: queue_cancel takes setup_mutex for the unrecorded list and then, separately, work->mutex. It never holds both, so it can't invert Submit's order.
  • Waiting entries: these are compacted in place and their references released.
  • Submitted, failing and deferred entries: these are marked and released in place, so the submitted_total / finished_total cutoffs are unchanged.
  • Double release: none is possible, because release_entry and release_unrecorded null what they release, so the later release on the normal path is a no-op.

What I ran. I did a full build in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^startup_(storage_|dstorage_|xcrdapi_|stub_check)' -E 'startup_audio_'

27/27 pass in both presets. That includes startup_storage_cancel, its WILL_FAIL control startup_storage_cancel_control, and startup_storage_worker_start.

Mutants in src/startup_stubs/xcrdapi.cpp. For each, I rebuilt in dev and ran the same 27 tests:

Mutant Result
tag_matches masks value too killed (startup_storage_cancel)
run_entry ignores cancelled killed (startup_storage_cancel)
tag read from +0x34 instead of +0x38 killed (cancel, control, worker_start)
queue_cancel skips the unrecorded list killed (startup_storage_worker_start)
queue_cancel skips the deferred list killed (startup_storage_worker_start)
queue_cancel skips submitted killed (startup_storage_cancel)
queue_cancel skips failing survives
following_chunk_ids doesn't stop at a cancelled entry survives
fail_waiting skip removed survives, equivalent: a cancelled entry is erased from waiting, never marked, so the guard can't fire
decoder reads IntermediateSize from +0x38 (the regression R0Y00 described) survives

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking.

  1. The decode-sizing regression isn't pinned. Case 8 is zlib-only, and that path never reads +0x34. So the last mutant, which puts back the tag-as-size read, passes every test. The one path that reads a size near the tag is zlib followed by BCPack. A combined zlib+BCPack request whose tag low word is large (0x7FFFFFFF) would pin it, with the same identical-completion and bounded-commit checks.
  2. The failing branch is unpinned. This is tedin7's first P3. cancelled_deferred_entries covers the unrecorded and deferred lists, but not an entry that sits in failing after an allocation failure.
  3. Read-ahead after a cancel is unpinned. No test shows that following_chunk_ids stops at a cancelled entry.
  4. Dead guard. The cancelled check in fail_waiting is unreachable as written (see the equivalent mutant). Either drop it or add a comment saying why it's kept.

Verdict: approve on c0d2977c. R0Y00's changes request on ece618ec still stands, so the merge waits for R0Y00 to re-check it.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. No GPU is involved in these tests.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on c0d2977c.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093809620 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#pullrequestreview-6093809620). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T22:08:13Z. **Review:** APPROVED --- I reviewed `c0d2977c` merged over current `main` `6cc46a3c`. The merge is clean and `git diff --cached --check` is clean. **R0Y00's ABI blocker on `ece618ec`.** - **Decode sizing:** on current `main`, `execute_request` sizes the inflate buffer from `+0x34` (`IntermediateSize`), and only when BCPack follows zlib. A zlib-only request inflates to `DestinationSize`. Nothing reads a size from `+0x38`. - **Tag reads:** this PR reads the tag through `offsetof(StorageRequest, cancellation_tag)`. `dstorage_error_record.h` pins that offset at `0x38` with a `static_assert`, so the tag and the decode size no longer overlap. - **Requested fixture:** Case 8 submits the same source-built zlib payload under tags `0x1111111100000001` and `0x222222227FFFFFFF`. It checks matching completion and bytes, no error record and bounded commit growth. **What I traced.** - **Lock order:** `queue_cancel` takes `setup_mutex` for the unrecorded list and then, separately, `work->mutex`. It never holds both, so it can't invert Submit's order. - **Waiting entries:** these are compacted in place and their references released. - **Submitted, failing and deferred entries:** these are marked and released in place, so the `submitted_total` / `finished_total` cutoffs are unchanged. - **Double release:** none is possible, because `release_entry` and `release_unrecorded` null what they release, so the later release on the normal path is a no-op. **What I ran.** I did a full build in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^startup_(storage_|dstorage_|xcrdapi_|stub_check)' -E 'startup_audio_' ``` 27/27 pass in both presets. That includes `startup_storage_cancel`, its `WILL_FAIL` control `startup_storage_cancel_control`, and `startup_storage_worker_start`. **Mutants** in `src/startup_stubs/xcrdapi.cpp`. For each, I rebuilt in `dev` and ran the same 27 tests: | Mutant | Result | |---|---| | `tag_matches` masks `value` too | killed (`startup_storage_cancel`) | | `run_entry` ignores `cancelled` | killed (`startup_storage_cancel`) | | tag read from `+0x34` instead of `+0x38` | killed (cancel, control, worker_start) | | `queue_cancel` skips the unrecorded list | killed (`startup_storage_worker_start`) | | `queue_cancel` skips the deferred list | killed (`startup_storage_worker_start`) | | `queue_cancel` skips `submitted` | killed (`startup_storage_cancel`) | | `queue_cancel` skips `failing` | **survives** | | `following_chunk_ids` doesn't stop at a cancelled entry | **survives** | | `fail_waiting` skip removed | survives, equivalent: a cancelled entry is erased from `waiting`, never marked, so the guard can't fire | | decoder reads `IntermediateSize` from `+0x38` (the regression R0Y00 described) | **survives** | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** 1. **The decode-sizing regression isn't pinned.** Case 8 is zlib-only, and that path never reads `+0x34`. So the last mutant, which puts back the tag-as-size read, passes every test. The one path that reads a size near the tag is zlib followed by BCPack. A combined zlib+BCPack request whose tag low word is large (`0x7FFFFFFF`) would pin it, with the same identical-completion and bounded-commit checks. 2. **The `failing` branch is unpinned.** This is tedin7's first P3. `cancelled_deferred_entries` covers the unrecorded and deferred lists, but not an entry that sits in `failing` after an allocation failure. 3. **Read-ahead after a cancel is unpinned.** No test shows that `following_chunk_ids` stops at a cancelled entry. 4. **Dead guard.** The `cancelled` check in `fail_waiting` is unreachable as written (see the equivalent mutant). Either drop it or add a comment saying why it's kept. **Verdict:** approve on `c0d2977c`. R0Y00's changes request on `ece618ec` still stands, so the merge waits for R0Y00 to re-check it. Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. No GPU is involved in these tests. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `c0d2977c`. This reply was AI-assisted.
JohnConnorNPC commented 2026-11-28 08:13:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T08:13:40Z.


Thanks for the cancellation work and for merging main. I reviewed head c0d2977c against current main (1f07b2c1): git merge-tree --write-tree 1f07b2c1 c0d2977c exits 0. R0Y00's ABI point is now met, because merged main uses +0x34 only to size a BCPack decode and the PR reads the tag through offsetof(StorageRequest, cancellation_tag), pinned by static_assert(... == 0x38). One regression still blocks the merge:

  1. A cancelled request breaks an uncancelled chunked zlib stream. In following_chunk_ids, the new if (e.cancelled) break; comes before if (e_source != source) { continue; }. A cancelled request for another source, placed between a stream's head and its continuation, therefore ends the scan and leaves continuation_ids empty. My repro queues a gate, A0 (a zlib file head in 2 pieces), B (a memory request), A1 (the continuation), a status and a fence, then cancels B after Submit. With the PR it gives status=0x80004005 A0=WRONG A1=WRONG B=untouched, and the piece logs size=0x200b -> zlib failed. With no cancel it gives status=0x00000000 A0=ok A1=ok B=copied. With only that line removed it gives status=0x00000000 A0=ok A1=ok B=untouched, and startup_storage_cancel still passes. Please drop the line. A cancelled id left in continuation_ids is never consumed, and the worker clears cached_streams once submitted is empty. Please also add this case to the test, since it is the read-ahead pin that pigalot found missing. R0Y00's changes request still stands, so it needs their re-review after the fix.

Also worth fixing:

  • Case 8a's bounded-commit check can't fail. Case 8 is zlib-only, so it never reaches the +0x34 read, and out = counters.PagefileUsage; reads the current commit after the fence, when the decode buffer has already been freed. A mutant that sizes a zlib-only inflate from the tag's low word reaches PagefileUsage=2051 MiB during the decode, yet the test still passes with rc 0 (before=3 MiB after=3 MiB). A zlib+BCPack request with a large tag low word, measured with PeakPagefileUsage or an observable decode size, would pin it. Until then, the docs sentence "pins identical completion, decoded bytes and bounded commit growth" overclaims.
  • The failing branch of queue_cancel is unpinned: no case cancels an entry that a failed-allocation Submit left in failing, and pigalot's mutant there survives.
  • CI ran none of the new tests. The Windows job reports 100% tests passed out of 41, and grep -c on its log returns 0 for startup_storage_cancel and 0 for startup_storage_worker_start. Please post a Windows ctest --no-tests=error -R '^startup_storage_(cancel(_control)?|worker_start)$' -V run on the new head.
  • Minor: the cancelled check in fail_waiting is dead code, because waiting entries are compacted out and never marked. Worker_start case C also sets e.cancelled = true on waiting entries directly, which is a state production code never reaches. The WILL_FAIL control passes on any non-zero exit, including cannot load XCRDAPI stand-in, so PASS_REGULAR_EXPRESSION "control expected cancelled r1" would pin the reason. The PR body still cites xcrdapi.cpp:519 reading +0x38, and its Verification numbers predate the merge.

Environment: Linux. I ran a clang-cl 19 cross build (/O2 -MT) of the trial merge with c3204a9c under Proton Wine, CPU only, in my own prefix. That merge and the merge with 1f07b2c1 have byte-identical xcrdapi.cpp, dstorage_error_record.h and both storage tests (git diff --quiet rc 0). This was not an MSVC or Windows run, and I did not run worker_start.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7236446499 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1869#issuecomment-7236446499). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-28T08:13:40Z. --- Thanks for the cancellation work and for merging `main`. I reviewed head `c0d2977c` against current `main` (`1f07b2c1`): `git merge-tree --write-tree 1f07b2c1 c0d2977c` exits 0. R0Y00's ABI point is now met, because merged `main` uses `+0x34` only to size a BCPack decode and the PR reads the tag through `offsetof(StorageRequest, cancellation_tag)`, pinned by `static_assert(... == 0x38)`. One regression still blocks the merge: 1. **A cancelled request breaks an uncancelled chunked zlib stream.** In `following_chunk_ids`, the new `if (e.cancelled) break;` comes before `if (e_source != source) { continue; }`. A cancelled request for another source, placed between a stream's head and its continuation, therefore ends the scan and leaves `continuation_ids` empty. My repro queues a gate, A0 (a zlib file head in 2 pieces), B (a memory request), A1 (the continuation), a status and a fence, then cancels B after Submit. With the PR it gives `status=0x80004005 A0=WRONG A1=WRONG B=untouched`, and the piece logs `size=0x200b -> zlib failed`. With no cancel it gives `status=0x00000000 A0=ok A1=ok B=copied`. With only that line removed it gives `status=0x00000000 A0=ok A1=ok B=untouched`, and `startup_storage_cancel` still passes. Please drop the line. A cancelled id left in `continuation_ids` is never consumed, and the worker clears `cached_streams` once `submitted` is empty. Please also add this case to the test, since it is the read-ahead pin that pigalot found missing. R0Y00's changes request still stands, so it needs their re-review after the fix. Also worth fixing: - Case 8a's bounded-commit check can't fail. Case 8 is zlib-only, so it never reaches the `+0x34` read, and `out = counters.PagefileUsage;` reads the current commit after the fence, when the decode buffer has already been freed. A mutant that sizes a zlib-only inflate from the tag's low word reaches `PagefileUsage=2051 MiB` during the decode, yet the test still passes with rc 0 (`before=3 MiB after=3 MiB`). A zlib+BCPack request with a large tag low word, measured with `PeakPagefileUsage` or an observable decode size, would pin it. Until then, the docs sentence "pins identical completion, decoded bytes and bounded commit growth" overclaims. - The `failing` branch of `queue_cancel` is unpinned: no case cancels an entry that a failed-allocation Submit left in `failing`, and pigalot's mutant there survives. - CI ran none of the new tests. The Windows job reports `100% tests passed out of 41`, and `grep -c` on its log returns `0` for `startup_storage_cancel` and `0` for `startup_storage_worker_start`. Please post a Windows `ctest --no-tests=error -R '^startup_storage_(cancel(_control)?|worker_start)$' -V` run on the new head. - Minor: the `cancelled` check in `fail_waiting` is dead code, because waiting entries are compacted out and never marked. Worker_start case C also sets `e.cancelled = true` on `waiting` entries directly, which is a state production code never reaches. The `WILL_FAIL` control passes on any non-zero exit, including `cannot load XCRDAPI stand-in`, so `PASS_REGULAR_EXPRESSION "control expected cancelled r1"` would pin the reason. The PR body still cites `xcrdapi.cpp:519` reading `+0x38`, and its Verification numbers predate the merge. Environment: Linux. I ran a clang-cl 19 cross build (/O2 -MT) of the trial merge with `c3204a9c` under Proton Wine, CPU only, in my own prefix. That merge and the merge with `1f07b2c1` have byte-identical `xcrdapi.cpp`, `dstorage_error_record.h` and both storage tests (`git diff --quiet` rc 0). This was not an MSVC or Windows run, and I did not run worker_start. This comment was AI-assisted.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1869:upstream-pr/1869'
git switch 'upstream-pr/1869'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1869'
git switch 'upstream-pr/1869'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1869'
git switch 'upstream-pr/1869'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1869'
git switch 'main'
git merge --squash 'upstream-pr/1869'
git switch 'main'
git merge --ff-only 'upstream-pr/1869'
git switch 'main'
git merge 'upstream-pr/1869'
git push origin 'main'
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!1862
No description provided.