Skip to content

DirectStorage: validate request sizes before allocation - #1785

Open
yaxis1 wants to merge 1 commit into
xcl-dev:mainfrom
yaxis1:fix/dstorage-request-allocation
Open

yaxis1 wants to merge 1 commit into
xcl-dev:mainfrom
yaxis1:fix/dstorage-request-allocation

Conversation

@yaxis1

@yaxis1 yaxis1 commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

  • Validate DirectStorage request sizes before allocation.
  • Use fallible allocations for source, zlib, and BCPack buffers.
  • Propagate allocation failures as E_OUTOFMEMORY.
  • Validate file bounds before reading.

Tested

  • git diff --check passed.

Not tested

  • Targeted Cargo tests were blocked by Windows Application Control
    (error 4551).
  • GPU validation and real-title regression testing were not run.
  • The proposed 256 MiB request ceiling needs compatibility review.

AI use

AI assistance was used to implement and review these changes.

@frenziedcoder

Copy link
Copy Markdown

NVIDIA test report for 73a6454: the description has no test run (Application Control), so here is one. Full suite green, the PR's own test passing, and a clean smoke pair (1654 vs 1654 frames).

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head 73a645459971606375a9f8191771253039a49aa7, no local changes.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 (debug): 864 passed, 0 failed, 42 ignored; all 18 hle::dstorage::tests pass. SKIPPED: 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 256 MiB ceiling against this title: across my earlier runs of it, XCL logged a sample of 479 DirectStorage requests (its first ones and every power-of-two request number, world load included). The largest destination and source in them was 922,384 B, about 300 times below the cap. This is a sample, not every request.

Regression run (scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen; XCL_PSO_PRELOAD=0 for both builds, because this machine's preload list holds the program of #1307)

base (4178e88, this PR's base; the same base run as in my report on #1747):

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 5080
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14604 MB

this PR:

xcl-smoke v1
commit: 73a645459971606375a9f8191771253039a49aa7
gpu: NVIDIA GeForce RTX 5080
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14600 MB

Not tested: the world load (where this title's DirectStorage traffic is: thousands of requests per 2 s with BCPack) on this head, so the change is not exercised on retail requests beyond the start screen; AMD; Wine.

AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.

@LocranKing

Copy link
Copy Markdown

Independent Windows 11 + 8 GB Ampere (RTX 3060 Ti) --release verification of exact head 73a645459971606375a9f8191771253039a49aa7 (merge-base 6c89285): full suite green (including the new DirectStorage allocation test) and clean 60 s retail smoke.

Tested

  • Hardware / toolchain: Windows 11 Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, Ampere, wave32 only), driver 32.0.16.2101 (621.01), rustc 1.100.0 (0ef1bc386 2026-11-09) (x86_64-pc-windows-msvc), DXC 1.9.2602.17 (21d28f72), --release.
  • cargo build --release -p xcl: exit 0.
  • Full workspace suite (cargo test --workspace --release --no-fail-fast -- --test-threads=4 --nocapture): 864 passed, 0 failed, 42 ignored. All hle::dstorage::tests and hle::bcpack::tests pass, including the new hle::dstorage::tests::zeroed_buffer_rejects_impossible_allocation. Expected host SKIPPED lines: 2 wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), 2 D3D12 debug layer (test_title_draws_with_a_root_signature_under_the_debug_layer, uploads_start_from_each_subresources_state), 1 heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form).

Regression run (scripts/smoke.ps1 -Seconds 60, --release)

Reference main (4178e88; exact merge-base 6c89285 was not smoked separately):

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1559)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15961 MB

PR #1785 (73a6454):

xcl-smoke v1
commit: 73a645459971606375a9f8191771253039a49aa7
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1597 (PresentX 1597)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15224 MB

Not tested: exact merge-base 6c89285 smoke, AMD/Intel GPUs, D3D12 debug layer, or extended world streaming past 60 s.

AI use: Antigravity (Gemini 4 Neon) built and ran the --release test suite and 60 s smoke locally and drafted this report from the captured outputs.

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #1381 #1438 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.

@JJAutoCompare

Copy link
Copy Markdown

PR #1785 - DirectStorage request-size validation

Tested commit 73a645459971606375a9f8191771253039a49aa7 (clean detached checkout).

Environment STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, wave range 8-32, DoublePrecisionFloatShaderOps=0). DXC/DXIL 1.9.2609.5, rustc 1.100.0 (0ef1bc386 2026-11-09). Used unoptimized dev/test profiles with debug info disabled and selected the A770. The D3D12 SDK debug layer was unavailable.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both succeeded outside the GPU lock.
  • cargo test -p xcl hle::dstorage::tests -- --nocapture reported 18 passed, 0 failed, 0 ignored, with zero explicit skips. The new test verifies that an impossible buffer reservation returns E_OUTOFMEMORY. Existing tests passed for zlib output sizing, BC1 queue decoding, and error recording on a request past EOF. The PR caps source, destination and intermediate sizes at 256 MiB each and checks the file range before allocating.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc lock. The 20 target summaries total 846 passed, 18 failed, 42 ignored (exit 101). All 18 DirectStorage tests passed again. The pass total includes 3 explicit SKIPPED lines (two no wave64, one no heap windows). Those paths provide no coverage.

Failures The library had 13 compute pipeline creation failures (0x80070057, including FP64 cases) and four output mismatches (FMA overflow control, pixel sampling with implicit LOD, f16 high-half preservation, and wave64 pixel reductions). The end-to-end test title failed its RSSetDepthBiasX dynamic depth-bias check (blue pixel, expected green).

Not tested A main baseline or retail-title smoke comparison, other GPU adapters, retail sample inputs (XCL_SAMPLE_* unset), request sizes at and above the 256 MiB boundary, and real memory pressure.

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1785-suite.log and published this report.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants