Skip to content

startup-runtime: loading-phase DirectStorage requests read past a file end and at non-zlib data #1198

Backlog

Description

@denn0x

During heavy loading, a console executable starts sending DirectStorage requests whose source ranges do not hold zlib data. They fail by the thousand, and the run ends a few minutes later.

Observed (local build of the #1135 stand-ins with a per-request trace; 284 s run, Windows 11 26300):

  • 71,000 requests in total. The first 43,200 all succeed (plain reads, zlib, multi-page zlib pieces, BCPack zero-filled per startup-runtime: decode BCPack DirectStorage requests instead of zero-filling #1139).
  • The first failure is a file request whose offset equals the file's size exactly, and whose source size is not plausible (0x98cabbec in one run, 0xd508a3ec in another). The same request, at the same offset, comes first in every run; only the size differs. A size that varies between runs suggests the executable read it from memory that was never written.
  • After it, about 19,000 zlib requests (options 0x200001) on four texture archives fail. Each request's offset plus its size, rounded up to 0x100, is the next request's offset, so the index the executable uses agrees with itself. But the bytes at those offsets are not a zlib stream. The nearest valid stream is several KiB away, and no other file the executable opened has a zlib stream at the same position.
  • Good and bad requests have the same request shape. Fields +0x14, +0x1c and +0x34 to +0x47 are all zero in both groups.
  • Every "inflated (short)" request (a zlib stream that ends before the destination size) has the same source layout: one zlib stream, zero padding up to a 0x100 boundary, then further streams. The stand-in stops after the first stream and leaves the rest of the destination unwritten. If the executable expects all of it, that would explain an index that is uninitialised by the time it is read.

Hypotheses, in order

  1. Short requests should inflate every 0x100-aligned stream in the source into the destination (multi-stream), not just the first. Not yet consistent: some short requests reach a non-zlib block partway through, and some decode to more than the destination size.
  2. Something earlier in the queue (multi-page piece slicing, or the BCPack zero-fill) gives the executable the wrong bytes for an index block.

Done when a source-built fixture pins the multi-stream layout (or rules it out), and a run past the loading screen shows no requests reading beyond the end of a file.

Related: #1144 (multi-page zlib), #1139 (BCPack), #1136.

AI-assisted (Claude Code).

Activity

  1. denn0x commented on Nov 24, 2026

    @denn0x
    CollaboratorAuthor

    Measured cause of almost all of the failing zlib requests: the request offset is a multiple of 64 KiB past a valid stream.

    Method: with a per-request trace (full 0x48-byte request and outcome), each zlib request on an RDS5 archive was matched against the archive's own boundary table. That table gives each interval's stored offset, stored size, trailing-byte count, decoded size and codec. A request matches an interval when source size == stored size - trailing bytes and offset - interval start is 4 KiB aligned.

    One run, about 30k zlib requests on RDS5 archives:

    outcome offset − interval start destination size == interval decoded size requests
    failed 14 × 64 KiB yes 19,393
    inflated 0 yes 9,153
    inflated (stream piece) 0 … 3 × 64 KiB no (one 64 KiB piece of a 256 KiB stream) ~1,040
    failed 1 … 13 × 64 KiB mixed ~40
    • All 19,393 shifted failures come from one family of four archives. Those archives also have about 140 requests each at shift 0 that succeed, including inside the offset ranges where the shifted ones fall. So the shift belongs to particular requests, not to the file layout.
    • At the shifted offset the bytes are not zlib, in this or in any other archive of the package (checked at every failing offset).
    • At offset − 14 × 64 KiB there is a stream of exactly the source size, with a valid Adler-32, that inflates to exactly the destination size.
    • The "stream piece" requests (one stream fetched as several destination-sized pieces) are the same pattern with small k. Pieces 2 and 3 failed only when the stream was no longer in the stand-in's 16-entry cache.

    Why the executable adds the shift is not known. The request fields at +0x10, +0x34, +0x38 and +0x40 do not carry it. A local experiment resolves such requests by looking back in 64 KiB steps for a stream that verifies and has the right decoded size. That is a workaround, not a fix: it is not proposed for merge. The useful next step is finding where the executable computes the offset for these requests.

  2. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    The chunked-stream and destination-capacity fixes are on main via #1214 (0fa43ad). The source-built test checks short final slices, bad zlib checksums and two queued submissions with matching offsets. The unrelated second submission fails and leaves its destination unchanged. This covers the known continuation shape.

    For the remaining report, please retry from 0fa43ad or later with the same configuration and record the first failed request category, whether it still begins at EOF, and totals grouped by EOF, decode failure and capacity rejection. A new trace is needed to tell whether the aligned multi-stream layout still occurs. Please keep raw inputs and traces local.

  3. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Independent Windows retest of the 14-page shift reported above. At the start of each of eight affected queues, the first request of a new submission already carried the extra 896 KiB. All eight requested a 1 MiB destination at page offset zero. Later source offsets advanced by the preceding compressed length rounded to 256 bytes. The same four file objects also served ordinary unshifted reads. This narrows the trace target to the construction of the first request in a batch.

    Independent retest welcome: compare one ordinary batch and one affected batch. Record the source offset before enqueue and at execution, destination page offset, compressed length, and whether the range matches the container directory. Please report the build and aggregate result only. The main development session is tracing the first offset producer. #1285 addresses the separate allocation before a read past EOF.

    Source-built layout comparison on Windows, PR #1311, commit 976540cc. For the 1024 x 1024 nine-mip BC7 fixture in 64 KiB standard mode, the old slot 10 implementation reported the first three mip starts at 4 KiB page indices 0, 256, 320. The candidate returns 96, 32, 16, with the packed tail at page 0. Both cover 352 pages. At 1024 x 512 the total changes from 176 to 192 pages. Neither fixture result produces the anomalous page count 0xFFC0 on its own. The loading observations above used a modified local diagnostic executable. The relationship between the layout change and a loading outcome remains unverified.

  4. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Two saved diagnostic runs contain 88,678 and 86,734 requests. Across all 175,412, the source offset, compressed length and destination capacity agree between enqueue and worker execution. Each run had eight affected batches whose first request already carried the offset discrepancy. Successful first requests also use the same enqueue call stack. The closest successful control matches the failing request's destination size, page offset and options, but uses a different file.

    The next useful observation is upstream of enqueue. For the first two entries in an affected batch and an ordinary batch, correlate the selected file/directory entry, its absolute physical offset, the batch base and entry delta (including units), and the resulting byte offset. A same-file control would let us test file selection as well as arithmetic. The existing traces record only the final offset. These observations come from modified diagnostic builds.

    PR #1323 supplies a source-built Windows queue control: the shifted request can select a different valid compressed stream and still report success. Please retain the byte comparison when reproducing. An aggregate result is sufficient.

  5. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    #1323 is now on main at e319360. I independently reran the two Windows Release storage tests, including both generated archive sizes. A shifted first offset can read a different valid page and return S_OK; the shifted request past EOF fails without modifying its destination, and the following correct request still succeeds. The remaining question is which caller first supplies an offset different from the archive directory, so #1198 stays open.

  6. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    #1331 is on main at 728e41d. On RTX 4060 Laptop and WARP, the native, mapped and AOT runners agreed on the two requested ranges, queue status, decoded pages and full synthetic BC7 output. Shifting just the first request changed 8,192 of 16,384 pixels with both requests still reporting success. The independent AOT-only mutation was also caught at the first request. This strengthens the offset differential; identifying the producer in the reported startup remains open here.

  7. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    We found same-file controls for entries after the batch head in both saved diagnostic traces. For each distinct failed zlib request, we searched the successful requests in that same run for the same volume, file ID, compressed length, destination capacity and options, with the source offset exactly 896 KiB lower. We also required a successful destination write and an inflated byte count equal to capacity.

    This found 83 distinct matched ranges in one run and 77 in the other, spanning all four affected files in each. There are 63 ranges common to both runs. No failing batch head has such a match. These pairs provide observed successful reads for checking the producer's entry selection. They still do not identify the arithmetic that produced the first offset, or justify applying a constant correction to general reads.

  8. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    For contributors following the loading-to-menu work, please link an existing producer-side fix or a source-built reproduction here if you have one. The useful comparison is the directory entry chosen by the reader, the base and relative offset used to form the request, and the offset received by the queue. A synthetic archive with two distinguishable records is sufficient. Main-menu navigation retests are being coordinated in #870.

  9. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    #1353 is on main at 4b166b7. The source-built native, mapped and AOT readers now request and decompress a complete sixteen-page record, then select the page within it. The single-page and sixteen-page cases passed on RTX 4060 Laptop and WARP. This supplies a reusable producer-to-queue control for the reported loading failure. The actual failing producer and its offset/count remain open here.

  10. mumba17 commented on Nov 24, 2026

    @mumba17
    Contributor

    Storage observations after confirming first-run setup, as asked on #870. Setup: RTX 3090, Ryzen 5 5600X, Windows 11 build 26300, release, the same launcher options as my #870 report. I applied one local diagnostic to xcrdapi.cpp with no behaviour change: a count of failed requests per outcome string, plus one line per "destination capacity exceeded" request recording its option bits and sizes. Only shapes and counts are below.

    First failed request class after confirm: destination capacity exceeded. Cumulative failed requests by outcome:

    Build While on the setup pages About 10 s after confirm Afterwards
    e1316e1c (main) capacity exceeded 15, zlib failed 2 capacity exceeded 144, zlib failed 4 flat: 5 more requests in the next 40 s; frames keep presenting until stopped at 312 s, with no fault; 7 Device::slot70 unsupported memory SRV arguments lines, the path in triggered02's 09:37 report
    4b166b7d + #1336 bcpack failed 13, capacity exceeded 15, zlib failed 2 bcpack failed 36→1,603, capacity exceeded 141→805, zlib failed 4→17,174 within 20 s: zlib failed 78,725, bcpack failed 5,699, read failed 156, zero page tokens at enqueue 28,142; then a fault

    Shape of the capacity-exceeded requests (554 logged across both builds, the same in each):

    • every one has zlib set, no BCPack format, a page-token destination (bit 21) and a file source;
    • the field at +0x38 (read as the uncompressed size) is 0 in every one;
    • the destination size is a multiple of 4 KiB from 0x1000 to 0xF000;
    • the stream inflates to more than that: mostly 0x10000 or 0x20000, otherwise 0x8000, 0x3000, 0x40000 or 0x80000, which is 2 to 16 times the destination;
    • 395 of 400 source offsets are not 64 KiB-aligned;
    • they arrive in bursts of up to 169 per submission;
    • none was served by the chunked-stream cache from startup: track decode length and destination capacity separately, support chunked zlib streams #1214. In each, the inflated stream was larger than the destination and no continuation request was found.

    Read together, this looks like a request asking for a window of a larger compressed record. That would make it the same shape as the whole-record-then-select-a-page control in #1353, with the page offset carried somewhere the stand-in doesn't read yet. That's a hypothesis only. I didn't identify the field.

    With #1336, most of the earlier BCPack blanks become decodes (blanks 191 → 14 at the same point), but rejections rise. The zlib-failure cascade that follows may be a consequence of the earlier failed loads rather than a separate cause.

    AI-assisted (Claude Code).

  11. JohnConnorNPC commented on Nov 24, 2026

    @JohnConnorNPC
    Collaborator

    The first failure class, destination capacity exceeded, from a per-request trace. Short version: these are requests for the first part of a compressed chunk, and delivering that part instead of failing the request removes the class. It does not finish the load; what happens after is at the end.

    Edited as asked below: the description of how the executable builds a request is removed, and what is left is request classes and counts as the stand-in sees them.

    Setup. main at bb6c9a0c with #1429, #1415 and #1390 merged on top (two small conflicts in xcrdapi.cpp, resolved by keeping both sides), plus a local trace line per executed request. clang-cl build under Wine 11.0 with vkd3d-proton, RTX 4070 Ti SUPER, same scripted first-run input in every run; the confirm step lands at 165 s each time.

    What the trace shows (225 s run, 44,266 requests, 293 failed):

    Request class Count
    all requests 44,266
    failed 293
    failed with destination capacity exceeded 205
    of those, destination ends exactly on a 64 KiB page boundary (page offset + destination size is a multiple of 0x10000) 205
    of those, carrying one page token 204
    • Typical: page offset 0xf000, destination 0x1000, stream inflates to 0x3000. Or page offset 0x1000, destination 0xf000, stream inflates to 0x10000, straight after a 0x1000-byte request on the same file that filled the start of the page.
    • In the five I followed by hand, no later request asks for the rest of the stream (nothing on that file at offset + destination size in the next 400 requests).

    So the caller wants the bytes up to the end of its page and the stream is longer.

    Experiment. Behind a local switch, a zlib request (no BCPack) whose stream inflates to more than the destination writes the first destination size bytes instead of failing:

    Run Failed at 220 s Outcome
    three PRs, no switch 20,290 C++ exception thrown inside the executable's BVH builder library at 241 s
    with the switch, run 1 241 wave of zlib failed from 220 s (13,440 by 240 s), then a null write in the executable at 244 s
    with the switch, run 2 40 330 s timeout, no further requests after about 205 s
    with the switch, run 3 (traced) 41 262 s timeout, no further requests after about 205 s

    With the switch the failures that remain before the wave are 37 bcpack failed and 3 or 4 zlib failed. The first bcpack failed requests have the same shape as above (one of them: page offset 0xc000, destination 0x4000), and a group of them steps its offset by 0x10000 with one unchanged source size. The BCPack decoder needs the full decoded size, which the request does not carry, so I have not tried those.

    What this does not explain.

    • The large zlib failed wave. That one is followed up in a later comment and in startup: answer XG slot 10 for layout 0x10a from a 64 KiB tile plan #1554; the lookup I first proposed for it here was wrong and is withdrawn.
    • Why the same build and input sometimes goes on into the wave and sometimes stops requesting. In the run that went on, the heartbeat's page tokens 0 at enqueue climbed from 726 to 17,056 between 190 s and 230 s; in the two that stopped it stayed at 503.

    This is one executable on a translation-layer host, three runs with the switch. It contradicts the rule from #1144 that a destination shorter than the stream must fail the request, for this request shape at least. The self-authored archive fixture asked for below (valid bounded output against malformed and truncated streams, with exact output, untouched destination bytes and completion status) comes before any change to that rule; I have not built it yet.

  12. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Thanks for isolating a request class. Keep the early range assertion, first capacity refusal, and later load failure as separate observations. Before changing the queue decompression contract, use a self-authored archive to compare a valid bounded output request with malformed and truncated compressed streams. Check exact output, untouched destination bytes, and completion status. Please reduce the private-reader field trace in the original comment to observable request classes and counts. Exact offsets and field layouts are useful in the self-authored fixture.

  13. JohnConnorNPC commented on Nov 24, 2026

    @JohnConnorNPC
    Collaborator

    Follow-up on the large zlib failed class, kept apart from the capacity class above. Two things: a retraction and a cause.

    Retraction. The "window" lookup I described (step back from a request offset to a stream of the same compressed size) is wrong for this class. In the one traced run where it served requests, 43 of them were answered from an unrelated chunk. Please disregard it; I have removed it from my trial build.

    What the failing requests are. Checked against the chunk tables of the two pool files that carried most of the class, parsed with boundary() from tools/texture_descriptors.py:

    Observation Count
    failing zlib failed requests on those two files 785
    of those, compressed size and destination size both equal one table entry, at that entry's file offset plus a constant 724
    constant 0xE0000 471
    constant 0x3A0000 250
    zlib chunks in those files that do not inflate on disk 0

    Consecutive failing requests map to consecutive table entries with the same constant. So the data is plain zlib and intact; the requests are for valid chunks at a place shifted by a multiple of 64 KiB. My earlier guess of a second codec is also dropped.

    Cause. Not the storage stand-in. The shift comes from the XG stand-in's slot-10 tiling answer, which a streaming executable uses to place each texture level in its pool. A desktop reserved resource orders the mips largest first; the pool files have them smallest first behind one shared tile. #1554 changes that answer for layout 0x10a and has the evidence (a rule that reproduces the level sizes of 39,283 texture records, a source-built test).

    Same executable, same scripted input, with and without #1554:

    without with
    zlib failed by 250 s 11,377 2
    chunk-table reads not starting at a chunk start 11,622 by 249 s 0 by 325 s
    run stopped at 253 s 330 s timeout, still requesting

    Still open, separately. The capacity class (your request for a self-authored archive fixture stands; I have not built it yet), bcpack failed on partial chunks (135 by 250 s), and a loading screen that draws blank.

  14. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Thanks for retracting the size-based fallback and for comparing the same scripted run with and without the slot-10 change. The chunk-start check makes the #1554 layout path the next one to verify on Windows. Please link the exact build in that follow-up and keep the remaining capacity, partial BCPack and blank-output observations separate. This issue stays open for the remaining storage failure cases.

  15. 23 remaining items

  16. sydney-0o commented on Nov 25, 2026

    @sydney-0o
    Contributor

    I ran a native Windows A/B control for both offset deltas reported in #1554. The test took the mip starts from the real XG slot-10 call and used their difference to form requests against generated RDS5 fixtures.

    Windows 10 x64 build 19045.6456, GTX 1080 Ti driver 32.0.15.8278, MSVC 19.31 Release, D3D12 debug layer off. Both XG DLLs were built from 9dcf1ae1. The negative control disabled only the tile64::Plan::supports branch. Both used the same Release storage consumer and XCRDAPI DLL from the local 6b50e3d7 build.

    BC7 shape, layout 0x10a Mip 1 start with plan / desktop Request offset delta
    1024 × 1024, 9 mips 2 / 16 tiles 0xE0000
    2048 × 2048, 10 mips 6 / 64 tiles 0x3A0000

    For each shape, I generated two archives via the write_intervals helper in tests/startup_storage_directory_batch.py. Both hold the same expected 4 KiB page at the plan offset. One has a different valid page at the shifted offset. The other has a stream with a bad checksum there. The requests were submitted via startup_stub_consumer.exe dstorage-directory. With the plan, both requests returned the expected bytes and S_OK. With the desktop fallback, the valid alternate page returned S_OK, and the checksum control returned E_FAIL with its destination untouched. All guards were intact. Three complete A/B repetitions agreed.

    The separate Windows Sandbox startup pair reached slot 10 and storage requests, then stopped early at the same access violation in both variants. The live loading phase remains unmeasured on this host.

    AI-assisted.

  17. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The field correction is on main in #2129 (4c1b27d). The public Xbox request ABI defines +0x38 as CancellationTag and +0x34 as IntermediateSize for zlib plus BCPack. I reran the Windows Release worker checks against the exact candidate: the large-tag zlib request succeeded within the test commit limit, and the allocation-failure/recovery and EOF/fence checks passed (2/2 overall). This removes the false size source. Please keep offset selection and overlong source ranges under separate investigation; a zero cancellation tag supplies no evidence about their intended output size. #1429 has the earlier ABI analysis and can retain its separate streaming work. https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/dstorage/structs/dstorage_request

  18. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The source-built generation check landed in #2083 (49f70c6). Windows Release passed both cases. Three requests reuse the same mapped page in one Submit. At their fences the results are E_FAIL → S_OK → E_FAIL. The first refusal leaves the sentinel, the valid request writes all 4,096 bytes, and the later refusal preserves those bytes and the earlier statuses. A consumer that reads the first refused destination as decoded data matches zero of 4096 bytes. This verifies the stand-in sequence. The observed startup batches still need their own offset/size attribution and status-to-consumer evidence.

    ctest --preset release --no-tests=error -R '^startup_storage_refused_reuse($|_accept_refused_control$)' --output-on-failure

  19. MasterDomino commented on Nov 25, 2026

    @MasterDomino
    Collaborator

    Retest after #2129: the capacity refusals remain

    Two startup runs on main at 19e04be9, which includes the #2129 field correction and the #2083 fixture. RX 9070 XT, Windows 11 build 26300, Release. Settings are the same as the cold/warm pair posted on #870: post-confirmation input, -MemoryGiB 32, -StartupBelow40, -Render -Translate. Both runs end at the slot 148 builder stop. A local counting-only diagnostic (not for PR) tracks each refused page request through its status queries. Counts only; no offsets, paths or logs.

    Failure causes at the last heartbeat:

    Cold run (290 s) Warm run (280 s) Pre-#2129 run (280 s)
    destination capacity 2,297 195 538
    bcpack 220 70 87
    zlib 7 3 3
    read at or past EOF 2 0 1
    Page requests ending exactly at the first 64 KiB page end: failed / all 2,526 / 7,434 (34%) 268 / 964 (28%) 629 / 2,308 (27%)
    Requests ending inside the page: failed 0 / 22,133 0 / 1,016 0 / 4,686
    Requests ending past the page: failed 0 / 2,602 0 / 100 0 / 761

    Status to consumer (refused page requests tracked through their status queries, as the title issues them):

    Cold Warm
    Refused page requests tracked 2,472 268
    Their status entry polled with IsComplete before the stop 2,457 268
    Never polled before the stop 15 0
    GetHResult queried 0 0
    Destination rewritten before or after the poll 0 0
    • The title only polls completion and never reads the error. It polls IsComplete on each failed request's status entry and never calls GetHResult, so a refused page completes from the title's point of view with its destination untouched. That is the sequence storage: implement next DirectStorage/BCPack slice (Part of #1198) #2083 checks, where a consumer reading the first refused destination as decoded data matches 0 of 4,096 bytes.
    • What this doesn't show. The counting doesn't observe reads, so it doesn't say whether the title then consumes those destinations. That needs a read watch on a refused destination, which I haven't run.

    AI-assisted.

  20. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The small-texture allocation and copy correction is on main in #2133 (ad394d2). Independent Windows Release verification gave 8 passed and one AddrLib skip. WARP and RTX 4060 Laptop each matched 1,536 rendered pixels from two mips written through the XG shim, with the reported allocation followed by a guard page. This covers the compact 4 KiB-aligned layout. For a startup A/B, use the same input and initial cache state and count capacity, BCPack, zlib and EOF separately. Please report the first remaining category with a reproducible source-built case if one is available. Keep the overall issue open for the remaining failures.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions