runtime: stop sizing the DirectStorage inflate buffer from CancellationTag #2121
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2129"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-25T01:06:06Z.
Change
The DirectStorage stand-in (
src/startup_stubs/xcrdapi.cpp) read request+0x38as an uncompressed size and sized its inflate buffer from it. In the publicDSTORAGE_REQUESTlayout the two unions are 16 bytes each, which putsDestinationSizeat+0x18,SourceSizeat+0x30,IntermediateSizeat+0x34andCancellationTag(UINT64, "an arbitrary UINT64 number used for cancellation matching") at+0x38. The offsets the stand-in already uses for the other fields agree with that layout.So the value at
+0x38is not a size. This also explains the observation on #1198 that the field "read as the uncompressed size" is 0 on the requests that exceed their destination: those requests carry no tag. A title that does set a tag would make the worker allocate and zero-fill up to 4 GiB per zlib request (twice that with BCPack), or fail the request withstd::bad_alloc.After this change:
DestinationSize(the documented size of the final result); the existing 512 KiB retry for chunked streams is unchanged;2 * DestinationSize + 64 KiB) and raises it toIntermediateSize, the documented number of BCPack bytes, when that is larger.Nothing else in request handling changes: the capacity check, the stream cache, the failure causes and the heartbeat are untouched.
Refs #1198
Related work
#1429 by @Holastor makes the same
+0x34/+0x38correction as part of a larger change (interleaved chunked streams, EOF fallback, async gamesave reads), and was opened first. It is currently far behindmainand conflicts insrc/startup_stubs/xcrdapi.cpp. This PR is only the field correction and its fixture, on currentmain, so it can be reviewed on its own; #1429's streaming work is unaffected and can rebase on top of it.Verification
Release build (
cmake --preset release, MSVC, Windows 11) at this branch's commit on top ofc580d904:That selection includes
startup_storage_alloc_failure,startup_storage_failure_counts(+ control),startup_storage_page_end_counts(+ control),startup_storage_consumer_pair(+ control),startup_storage_worker_start,startup_storage_refusal_order,startup_dstorage_destination,startup_storage_directory_batch,startup_inflate,startup_stubsandcpu_native_dstorage.Fail-first control: with
src/startup_stubs/xcrdapi.cppreverted toc580d904and the updated test kept,startup_storage_alloc_failurefails withand passes again with the change restored.
I did not run the Debug configuration or the
prpreset.Evidence and follow-up
tests/startup_storage_alloc_failure.cppis the only fixture that depended on the old reading: it produced its allocation failure by writing 1.5 GiB at+0x38. It nowIntermediateSize(+0x34) on a zlib + BCPack request, andCancellationTagunder the job commit limit; it must complete withS_OKand the right bytes.Other storage fixtures still write a size at
+0x38(startup_storage_consumer_pair,_failure_counts,_page_end_counts,_refusal_order,_worker_start). They pass unchanged because that value is no longer read; I left them alone to keep this PR to one behavior, and can drop those writes in a follow-up if preferred.Limits and assumptions:
+0x38..+0x3f, so this change did not alter that run; it removes a wrong read rather than fixing an observed failure.IntermediateSizeis not documented. The stand-in honours it as given; an unserviceable value fails that request and the worker keeps running, which is what the updated fixture checks.DestinationSize. What the console does with such a request is not publicly documented and this PR does not guess at it.Checklist
This change was prepared by Claude Opus 5.5.
🤖 Generated with Claude Code
https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc