DirectStorage: validate request sizes and bounds before buffer allocation (#1392) #1438
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1438
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1438"
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?
@hajduzsolt on GitHub · 2026-11-24 15:58 UTC · original
hajduzsolt:fix/dstorage-request-bounds-validation→main· +157 −6 · 1 files · 2 commits · openRuntime fix verified with unit tests and RX 9070 XT smoke run.
What is in it
Tested
cargo test --workspace -- --test-threads=4passed.Regression run
main:
PR:
Not tested
XCL_NETWORK=0) and NVIDIA / wave32-only GPUs.AI use
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@crosettiremi on GitHub · 2026-11-24 18:10 UTC · original · edited 2026-11-24 18:23 UTC
Independent downstream observation on Windows / RX 7900 XT. A cold-cache build based on main
9e3831ewith #789 and #1514 streamed title assets after account selection, then exited 0xc0000409 under a 28 GiB Windows job limit. Peak sampled process commit was 28,088 MB. A stack scan on the terminating thread with the matching XCL PDB found the Rust OOM handler, miniz_oxide inflate, and the DirectStorage queue worker. The exact request and requested allocation size are unknown.Your source-buffer checks apply cleanly to that build. There is a separate allocation in the zlib output path: decompress_to_vec_zlib_with_limit bounds length but allocates the output infallibly. I tested a local fallible-output variant with valid zlib data, exact and unspecified intermediate lengths, zero padding, checksum failure, and an injected allocation refusal during buffer growth. The focused fixture passed and the refusal returned E_OUTOFMEMORY. Hardware validation of the combined changes is pending.
Hardware follow-up on the same RX 7900 XT, cold application cache, 28 GiB job limit. With the source checks plus fallible zlib output, the release built and all 19 downstream DirectStorage tests passed. Run 91 selected Player1 at 49 s. In the 60–150 s samples, XCL counted 88,084 attempted requests and 109 failures. Destination tracing found requests with options 0x200001 (file/zlib to physical pages) still carrying a zero page number when the worker tried to write. The last positive present sample ended at 174.217 s. The final captured frame was dark. Process exit was again 0xc0000409 and peak sampled process commit was 28,566 MB. This time the matching-PDB stack scan showed the allocator failure in Chain::detile_level, title_textures::subresources and a subresources_on worker. This run did not establish that the zlib allocator itself encountered pressure, and changing it did not eliminate process-level memory exhaustion.
@DavidM1911 on GitHub · 2026-11-24 18:52 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@hajduzsolt on GitHub · 2026-11-24 19:25 UTC · original
Thanks for flagging the duplicate section. The earlier Tested/Regression text and pending placeholder are stale; the later Tested/Regression sections contain the newer results. I have left the smoke-containing description intact for the automated verifier, so the duplicate still needs cleanup there.
@hajduzsolt on GitHub · 2026-11-24 19:34 UTC · original
Thanks for flagging this. I removed the stale duplicate section and preserved both existing smoke blocks verbatim.
@gigabyteZ390 on GitHub · 2026-11-24 20:55 UTC · original
Tested
370246cdf1990ae47015cd6c0b3268a252b8f96e(head of #1438) against its baseb9b6ea62080cc62fc19e212033372d01c6214e5c, on NVIDIA (wave32), the case listed under Not tested.Tested
stable-x86_64-pc-windows-msvc; DXC 1.9.2609; debug for the tests, release for the smoke runs.\scripts\test.ps1on the head, withXCL_SAMPLE_RPF/_DLLS/_TTPFset: 890 passed, 0 failed, 42 ignored;unvalidated_request_sizes_rejected_without_allocatingpassesSKIPPEDon this adapter:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows) – the same three as on mainscripts/smoke.ps1, a retail title, 60 s, base and head each run twice and the second run recorded (shader caches warm):base:
PR:
xcl.logactivity lines): 9767 requests, 650 MB, 0 failed on the base and on the head alike. The logged requests were all file sources (zlib or plain); no physical-page request was logged.The new test passes without the fix. Applied alone (only the test hunk) onto
b9b6ea6,cargo test -p xcl --lib unvalidated_request_sizes_rejected_without_allocatinggives1 passed. Both cases already returned these HRESULTs before the PR: a file read past its end gotE_END_OF_FILEfromread_exact_at, and the unreadable memory source gotE_ACCESS_VIOLATION; the base just allocatedsource_sizebytes first (dstorage.rs:880and:897onb9b6ea6). The test checks the HRESULTs, not that nothing is allocated before the checks, so it does not show the fix.Not tested
Written by Claude Code (Claude Opus 5.5) from runs on this machine; checked before posting.
@throny on GitHub · 2026-11-25 00:27 UTC · original
Two contributors checked independently and found that #1381 #1785 solves the same problem (for #1392) in a different way: #1607, group D54. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@anes66 on GitHub · 2026-11-25 06:31 UTC · original
CPU-only DirectStorage error-path verification on exact head
370246cdf1990ae47015cd6c0b3268a252b8f96epassed. Optional companion b6a0a3d is directly on that head and adds one test only.Tested
Request::check(false)and targets an eight-byte sentinel buffer.E_END_OF_FILEbefore the 128 MiB source allocation. The in-bounds span instead returnsE_OUTOFMEMORY; both leave every destination byte unchanged. The real D3D12 device pointer stays null.cargo test --locked -p xcl --lib file_bounds_precede_allocator_refusal_and_refusal_preserves_destination -j 2 -- --nocapture --test-threads=1: 1 passed / 0 failed / 0 ignored / 0 skips.unvalidated_request_sizes_rejected_without_allocatingfilter: 1 passed / 0 failed / 0 ignored / 0 skips.E_OUTOFMEMORYinstead ofE_END_OF_FILE; replacing the fallible file-source buffer with the originalvec!aborts the child withmemory allocation of 134217728 bytes failed. Both cause the parent test to fail. Restored before final passing runs and commit.Not tested
Full queue/status propagation for the new case (it calls
executewith an explicit syntheticFileInner), compressed contents, zlib/BCPack intermediate/output allocation failures, physical-page destinations, actual system memory pressure, release, GPU/workspace suite, retail smoke or newer-main integration. No claim that this PR fixes a particular retail crash. The job cap is child-only and does not change the parent or system configuration.AI use: Codex (GPT-6; exact variant unavailable) wrote the test and temporary controls, ran CPU verification and prepared this report.
@hajduzsolt on GitHub · 2026-11-25 14:38 UTC · original
Thank you for checking the regression against the base, and thanks to @anes66 for the test contribution. Commit
81e9b62adds the isolated allocator-refusal test: an out-of-bounds source returnsE_END_OF_FILEbefore allocation, while an in-bounds source reportsE_OUTOFMEMORYunder the child-only memory cap; both leave the destination unchanged.cargo test -p xcl --lib file_bounds_precede_allocator_refusal_and_refusal_preserves_destination -- --test-threads=2: 1 passed, 0 failed, 0 ignored.cargo test --workspace -- --test-threads=2: passed, 0 failures; the xcl unit suite reported 842 passed and 22 ignored, with additional workspace and documentation tests passing.The updated head is queued for automated RX 9070 XT smoke re-verification.
@DavidM1911 on GitHub · 2026-11-26 05:13 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:A callee gained a parameter on
main; the PR's call sites need updating on rebase.— Devin
@gut0to on GitHub · 2026-11-24 18:57 UTC · original · reviewed
The newer smoke blocks and test results are useful, but the description still contains an earlier duplicated Tested/Regression section with a literal
\textplaceholder and a pending-human-verification note. It reports different counts and empty smoke blocks, which conflicts with the later complete results and makes the current evidence ambiguous. Could you remove the stale section and leave one canonical Tested/Regression report? AI-assisted review; I checked both sections in the current description.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.