Skip to content

startup: check that refused storage requests leave the destination and later requests intact - #1664

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
RenzoWit35:startup/storage-queue-refusal-order
Nov 24, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
RenzoWit35:startup/storage-queue-refusal-order

Conversation

@RenzoWit35

Copy link
Copy Markdown
Contributor

Change

Adds startup_storage_refusal_order, a device-free test of the DirectStorage stand-in (src/startup_stubs/xcrdapi.cpp), registered like startup_storage_alloc_failure. Test-only: no change in src/.

It writes its own file (patterned raw bytes, then one stored-deflate zlib stream) and submits one batch of 8 requests, each followed by its status entry and an EnqueueSignal fence:

# path request expected
0 raw valid, offset 0 S_OK, exact bytes
1 raw offset == file size E_FAIL, destination untouched
2 raw size 0x98cabbec at offset 0 E_FAIL, destination untouched
3 raw valid, offset 4096 S_OK, exact bytes
4-7 zlib the same four shapes same

Every destination (4096 bytes) is poisoned with 0xA5 and compared over its whole length. The test also checks that each fence runs after its own status entry and before the next, in queue order, and that the stand-in's log names read failed for each refusal. docs/startup-runtime.md gets one bullet.

No per-file offset and no compressed-size fallback is added (as asked on #1586).

Verification

Commit under test: this commit on top of origin/main c864f13. Windows 11 26300, MSVC 14.51.

  • cmake --preset dev; cmake --build --preset dev --target startup_storage_refusal_order startup_storage_file_range startup_storage_alloc_failure startup_storage_worker_start startup_storage_root_check startup_dstorage_file_read_check startup_inflate_status
  • ctest --preset dev -R "startup_storage|startup_dstorage|startup_inflate" --no-tests=error: 9/9 passed, 0 skipped (77), including startup_storage_refusal_order.
  • The same with --preset release: 9/9 passed, 0 skipped.

Negative controls (run on the earlier base 734217e; single-point edits of xcrdapi.cpp, rebuilt, reverted, not committed):

  • Refusal no longer sets the pending failure (if (failed && self && strcmp(outcome, "read failed"))): fails, "request 1 status is E_FAIL, got 0x00000000" (also requests 2, 5, 6, and the fence checks).
  • A status entry no longer clears the pending failure (result = self->pending): fails, "request 3 status is S_OK, got 0x80004005" (the valid request after a refusal), likewise 4 and 7.
  • The read-failed branch writes one destination byte: fails, "request 1 refused but its destination changed" (also 2, 5, 6).

Evidence and follow-up

Refs #1586. Relates to #1198 (the same request shapes: offset at EOF, implausible size). Existing coverage left as is: startup_storage_file_range (helper level), the file-source negatives in startup_stub_consumer.cpp, the failure-order tests in startup_storage_alloc_failure.cpp. Open PRs #1429, #1390, #1616, #1622 and #1523 do not add a test of this shape.

Not shown: that the title proceeds correctly after a refusal, and anything about the offset shift itself. A refusal happens in two layers (the bound check in read_storage_file and the read), so the test pins the observable behaviour, not which layer refuses.

AI-assisted.

@R0Y00
R0Y00 merged commit f674edf into R0Y00:main Nov 24, 2026
5 checks passed

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent technical peer review of PR #1664 at head commit a19dc4a3aaf4c8171427643c4c82a3c70976763a.

Summary

  • Scope & title-neutrality: clean (CMakeLists.txt, docs/startup-runtime.md, tests/startup_storage_refusal_order.cpp). Zero production code is modified.
  • No defects found in the test or documentation.

Findings

  • Nit (tests/startup_storage_refusal_order.cpp):
    • plan[4] and plan[7] share the exact same (zlib=true, offset=zlib_offset, size=stream.size()) tuple, so outcome_of (which scans log_text from offset 0) returns the log line from plan[4] for both i=4 and i=7.
    • outcome_of searches for '\r' as the line terminator, assuming CRLF output from X2W_TRAP_LOG.

Verification Executed Locally

  • Linux:
    • git diff --check origin/main...HEAD — passed.
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py — passed (16 Markdown files, 350 links).
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py — passed (1278 files).
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207):
    • x2w_pipe.py win2025 --batch 1667 1664:
      • Debug (--preset dev): startup_storage_refusal_order 1/1 passed (0.03s).
      • Release /O2 (--preset release): startup_storage_refusal_order 1/1 passed (0.03s).
  • Local mutation check:
    • Temporarily injected a broken relative link into the new DirectStorage refusal order entry in docs/startup-runtime.md and ran tests/docs_links_check.py — failed as expected with docs/startup-runtime.md:513: nonexistent_target.md (exit=1), then restored via git checkout -- .. (The C++ test itself is Win32-only and was verified on Windows Server 2025 Debug and Release /O2.)

AI-assisted; commands listed were executed locally.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Built and ran this at a19dc4a3. It passes here, and I checked that the layer under it is not hollow.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^startup_storage_refusal_order$' -V
1/1 Test #73: startup_storage_refusal_order ... Passed

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100.

Independent check on the boundary it leans on

The refusals here come from read_storage_file in src/startup_stubs/dstorage_file_read.h, so I mutated its three boundary comparisons and rebuilt XCRDAPI.dll each time (timestamp checked):

mutation result
count > size - offset -> >= (a read ending exactly at EOF refused) caught
offset > size -> >= (a read starting at EOF refused) caught
ReadFile result read == count -> read > 0 (short read accepted) caught

So the "offset == end of file" case in the new fixture is doing real work, and the short-read case is guarded too.

What I think is still open

The fixture covers the ordering within one Submit on one queue. Two things it does not appear to touch, and both are the kind that a later refactor could break silently:

  1. the same sequence submitted on two queues, where the fuse is that a refusal on queue A must not advance B's status entries;
  2. a status array smaller than the number of requests in the Submit — the entries past its capacity are the interesting ones, and nothing here sizes the array below the request count.

Neither is a defect in this change; they are the cases I would add next if you want this fixture to be the one that guards the ordering contract. I can write either against your branch or as a follow-up with Refs #1664.

One wording point

The header comment says the check covers "the whole poisoned buffer of each refused destination". Reading the test, the poisoned region checked is the destination buffer of each refused request, which is what matters — if the intent is the whole capacity including the bytes past the declared size, that is not asserted. Worth a half-sentence either way, because "whole buffer" is the kind of phrase someone will later trust without reading the code.

Verdict

Reviewed a19dc4a3. Correct as written, the ordering assertions are real, and the helpers underneath hold their boundaries on three independent mutations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants