startup-runtime: soft assert in a chunked streaming read #1136
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#1136
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@denn0x on GitHub · 2026-11-24 01:45 UTC · original
Problem
Under
tools/startup/run.ps1, one soft assert (anint3followed by a continuation) fires about ten times asecond once texture streaming starts. The surrounding code reads a compressed stream in chunks, and the assert
checks that a read length ends on a chunk boundary; the requested length ends inside a compressed chunk.
What is known
-ContinueAsserts Nthe run continues; without a debugger the title steps over it.Done when
The cause is identified (which stand-in answer produces the length) and the assert no longer fires, or the
finding is documented with a reproduction that does not need game files.
Context:
docs/startup-runtime.md(#1135). Do not attach game files, dumps or logs that contain addresses or names from an executable; describe results in terms of the component tested.AI-assisted (Claude Code).
@Holastor on GitHub · 2026-11-24 03:23 UTC · original
Claiming #1136.
I am taking this issue to investigate and resolve the chunked streaming read failure and assert in the DirectStorage stand-in (
src/startup_stubs/xcrdapi.cpp).n \times Dstream is enqueued asndestination-sized requests (piece 0 with zlib header at base offsetB, piecesk \ge 1offset byB + k \times Dwithout headers).(source, base_offset, compressed_size)and serve subsequent slices[k \times D, (k+1) \times D)with bounded LRU eviction.n \times DRFC 1950 stream enqueued asnslice requests, verifying exact byte readback across all pieces.E_FAILand that destination memory remains untouched.devandreleasepresets.@Holastor on GitHub · 2026-11-24 03:30 UTC · original
Cause Analysis & Source-Built Solution
1. Root Cause
In DirectStorage streams under the startup stand-in, texture streaming assets are enqueued as
npiece requests targeting 64 KiB destination pages/buffers:B, compressed sizeS, destination sizeD, starting with a standard zlib header (78 da/78 01).B + k \times D, compressed sizeS, destination sizeD. The offset in the request is stepped by the uncompressed destination slice size (k \times D), not the compressed stream offset, soReadFileatB + k \times Dreads mid-stream bytes that do not start with a zlib header.Without chunk caching:
n \times D > Dand bounds are strictly enforced.k \ge 1fail immediately on header validation ("zlib failed: header ...").2. Implementation (
src/startup_stubs/xcrdapi.cpp)StreamCache: thread-safe LRU cache storing up to 16 uncompressed streams indexed by(source, base_offset, compressed_size).has_following_chunk(self, source, offset, source_size, destination_size): checks whether the queue'ssubmittedorwaitingdeques contain an upcoming request matching(source, source_size)with offsetB + D.produced > destination_sizeANDhas_following_chunk(...)is true, the full decompressed buffer is stored instream_cache, and slice 0 ([0, D)) is served to Piece 0's destination."destination capacity exceeded"), leaving destination memory completely untouched.k \ge 1Handling:stream_cache.get_slice(source, offset, source_size, destination_size, output)matches the cached entry by(source, compressed_size)whereoffset >= base_offset.delta = offset - base_offset.delta + destination_size <= cached_size, slices[k \times D, (k+1) \times D)are extracted directly from the cache and written to the destination ("inflated (slice from stream cache)").delta + D > \text{cached\_size}) or mismatched compressed sizeSmisses cache and fails withE_FAIL(0x80004005), leaving destination memory untouched.3. Source-Built Regression Fixtures (
tests/startup_stub_consumer.cpp)Extended
startup_stub_consumerunder scenariodstorage:4 \times 64\text{ KiB}), compressed with stored RFC 1950 zlib.0, 64\text{ KiB}, 128\text{ KiB}, 192\text{ KiB}.S_OKand every 64 KiB destination buffer matches the exact plain data slice.500\text{ KiB} > 128\text{ KiB}) into a buffer prefilled with0xEE.E_FAIL(0x80004005), and its buffer remains 100% untouched (0xEE).E_FAIL(0x80004005), and its buffer remains 100% untouched (0xAA).4. Verification Results
Environment: Windows 11 Pro x64 (build 26100), MSVC 19.51, Ninja.
Release Preset:
Dev Preset:
Linters:
tests/docs_links_check.pyandtests/bidi_controls_check.pypass with 0 errors.@Holastor on GitHub · 2026-11-24 03:37 UTC · original
PR #1214 is now open for review on top of main (
c02af631) following the merge of #1135: #1214