DirectStorage: zero-pad short uncompressed requests to destination size (#1488) #1625

Open
github-bot wants to merge 1 commit from github-bot/gh-1625 into main AGit
Owner

@⁠slopgobblercobbler on GitHub · 2026-11-24 18:23 UTC · original
slopgobblercobbler:fix/dstorage-uncompressed-padding → main · +73 −1 · 1 files · 1 commits · open

Summary

Pads short uncompressed DirectStorage requests to destination size in crates/xcl/src/hle/dstorage.rs (Issue #1488, finding XCL-BT-004):

  1. Uncompressed request payload safety:
    • In uncompressed DirectStorage requests (!r.zlib() && bc == 0), titles may specify source_size < destination_size (r.source_size < n).
    • Previously, src was allocated with length r.source_size and assigned directly to payload.
    • On physical page writes (r.dest_physical_pages()), &payload[..n] panicked with a slice index out-of-bounds error.
    • On virtual memory writes, std::ptr::copy_nonoverlapping(payload.as_ptr(), r.destination, n) caused a heap-buffer over-read reading past the end of payload.
    • Enforced if bc == 0 && !r.zlib() && payload.len() < n { payload.resize(n, 0); }, zero-padding payload to the full requested destination size n.
  2. Unit tests:
    • Added uncompressed_request_with_short_source_is_zero_padded in dstorage.rs asserting clean completion without panic or buffer over-read across both virtual memory and physical page destinations, verifying exact source data copying and zero-padding of remaining destination bytes.

Changes

  • crates/xcl/src/hle/dstorage.rs:
    • Zero-pad uncompressed payload when source_size < destination_size.
    • Synthetic unit test verifying padding and preventing slice panic/heap over-read.

Tested

  • Windows 11 x64, Rust MSVC stable.
  • cargo test -p xcl -- dstorage: 18 passed, 0 failed.
  • Clean diff: zero trailing whitespace, clean rebase on latest upstream/main, GPL-2.0-only compliant, zero retail game data or keys.

Not Tested

  • Real-time retail title streaming under DirectStorage compression queues.

AI Use

Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity

**@⁠slopgobblercobbler** on GitHub · 2026-11-24 18:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1625) `slopgobblercobbler:fix/dstorage-uncompressed-padding` → `main` · +73 −1 · 1 files · 1 commits · open ## Summary Pads short uncompressed DirectStorage requests to destination size in `crates/xcl/src/hle/dstorage.rs` (Issue #1488, finding `XCL-BT-004`): 1. **Uncompressed request payload safety**: - In uncompressed DirectStorage requests (`!r.zlib() && bc == 0`), titles may specify `source_size < destination_size` (`r.source_size < n`). - Previously, `src` was allocated with length `r.source_size` and assigned directly to `payload`. - On physical page writes (`r.dest_physical_pages()`), `&payload[..n]` panicked with a slice index out-of-bounds error. - On virtual memory writes, `std::ptr::copy_nonoverlapping(payload.as_ptr(), r.destination, n)` caused a heap-buffer over-read reading past the end of `payload`. - Enforced `if bc == 0 && !r.zlib() && payload.len() < n { payload.resize(n, 0); }`, zero-padding `payload` to the full requested destination size `n`. 2. **Unit tests**: - Added `uncompressed_request_with_short_source_is_zero_padded` in `dstorage.rs` asserting clean completion without panic or buffer over-read across both virtual memory and physical page destinations, verifying exact source data copying and zero-padding of remaining destination bytes. ## Changes - `crates/xcl/src/hle/dstorage.rs`: - Zero-pad uncompressed payload when `source_size < destination_size`. - Synthetic unit test verifying padding and preventing slice panic/heap over-read. ## Tested - Windows 11 x64, Rust MSVC stable. - `cargo test -p xcl -- dstorage`: 18 passed, 0 failed. - Clean diff: zero trailing whitespace, clean rebase on latest `upstream/main`, GPL-2.0-only compliant, zero retail game data or keys. ## Not Tested - Real-time retail title streaming under DirectStorage compression queues. ## AI Use Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
In uncompressed requests (!r.zlib() && bc == 0), if payload.len() < n
(destination size), zero-pad payload up to destination size via
payload.resize(n, 0).

This prevents slice out-of-bounds panics at &payload[..n] on physical
page destinations and heap buffer over-read undefined behavior on virtual
destinations when source_size < destination_size (finding XCL-BT-004 from
issue #1488).

Add synthetic unit test verifying uncompressed requests with
source_size < destination_size complete cleanly and pad with zeros.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:59:50 +00:00
Author
Owner

@⁠Anon64 on GitHub · 2026-11-24 19:33 UTC · original

Regression run for this PR: head 58fa588, based on main 9e3831e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, in one batch with the main run.

main 9e3831e:

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1536 (PresentX 1536)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 97380 MB

this PR:

xcl-smoke v1
commit: 58fa588e247dd34f70a2edb5c35c8a08aee47679
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1530 (PresentX 1530)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 103101 MB

No device removals or crashes; 99 % of main's frames, 105 % of its peak commit.

Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies from run to run, so it says little about this PR.

Not tested: the whole suite; whether the title reaches the changed code in these 60 s.

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

**@⁠Anon64** on GitHub · 2026-11-24 19:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/1625#issuecomment-7142264784) Regression run for this PR: head `58fa588`, based on `main` `9e3831e`. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, `XCL_NETWORK=0`, A pressed every 4 s from 20 s, `scripts/smoke.ps1` on a retail title for 60 s, in one batch with the `main` run. main `9e3831e`: ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1536 (PresentX 1536) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 97380 MB ``` this PR: ``` xcl-smoke v1 commit: 58fa588e247dd34f70a2edb5c35c8a08aee47679 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1530 (PresentX 1530) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 103101 MB ``` No device removals or crashes; 99 % of main's frames, 105 % of its peak commit. Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies from run to run, so it says little about this PR. **Not tested:** the whole suite; whether the title reaches the changed code in these 60 s. Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 20:46 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 20:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/1625#issuecomment-7144041383) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:00 UTC · original

PR #1625 Windows verification

Tested clean detached head 58fa588e247dd34f70a2edb5c35c8a08aee47679 on STOR-WINLAB, Windows 11 Enterprise Evaluation x64 (10.0.26200, build 26200). The guest reports an AuthenticAMD processor (family 23, model 113, stepping 0, ~3.9 GHz) and an Intel Arc A770 with driver 32.0.101.9175. DXC was 1.9.2609.5. Rust was rustc 1.100.0 (0ef1bc386 2026-11-09), x86_64-pc-windows-msvc. The dev and test profiles ran with debug info and incremental compilation disabled.

Tested

  • cargo build --workspace completed successfully.
  • cargo test --workspace --no-run completed successfully and produced 19 test executables.
  • cargo test -p xcl --lib hle::dstorage -- --nocapture --test-threads=1 --skip hle::dstorage::tests::error_record_has_the_failed_requests_offset_source_size_and_tag ran outside the Arc mutex with XCL_ADAPTER=NONE_CPU_ONLY. 17 passed, 0 failed, 0 ignored, 0 SKIPPED markers, 732 filtered out.
  • The PR changes only crates/xcl/src/hle/dstorage.rs. Its regression test verified that an uncompressed memory request preserved all 40 source bytes and wrote 48 zero bytes to fill the 88-byte destination. The log confirms execution of both the virtual-memory and mapped physical-page cases.

Not tested

Execution covered the focused CPU DirectStorage tests only, with the rest of the workspace compiled. The full workspace GPU suite and retail-title smoke runs were omitted. One existing DirectStorage test was filtered out because it deletes its temporary file fixture. Retail BCPack samples were omitted.

AI use

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 pr1625-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/1625#issuecomment-7153361311) # PR #1625 Windows verification Tested clean detached head `58fa588e247dd34f70a2edb5c35c8a08aee47679` on STOR-WINLAB, Windows 11 Enterprise Evaluation x64 (10.0.26200, build 26200). The guest reports an AuthenticAMD processor (family 23, model 113, stepping 0, ~3.9 GHz) and an Intel Arc A770 with driver 32.0.101.9175. DXC was 1.9.2609.5. Rust was rustc 1.100.0 (0ef1bc386 2026-11-09), x86_64-pc-windows-msvc. The dev and test profiles ran with debug info and incremental compilation disabled. **Tested** - `cargo build --workspace` completed successfully. - `cargo test --workspace --no-run` completed successfully and produced 19 test executables. - `cargo test -p xcl --lib hle::dstorage -- --nocapture --test-threads=1 --skip hle::dstorage::tests::error_record_has_the_failed_requests_offset_source_size_and_tag` ran outside the Arc mutex with `XCL_ADAPTER=NONE_CPU_ONLY`. 17 passed, 0 failed, 0 ignored, 0 SKIPPED markers, 732 filtered out. - The PR changes only `crates/xcl/src/hle/dstorage.rs`. Its regression test verified that an uncompressed memory request preserved all 40 source bytes and wrote 48 zero bytes to fill the 88-byte destination. The log confirms execution of both the virtual-memory and mapped physical-page cases. **Not tested** Execution covered the focused CPU DirectStorage tests only, with the rest of the workspace compiled. The full workspace GPU suite and retail-title smoke runs were omitted. One existing DirectStorage test was filtered out because it deletes its temporary file fixture. Retail BCPack samples were omitted. **AI use** 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 `pr1625-focused.log` and published.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1625/head:github-bot/gh-1625'
git switch 'github-bot/gh-1625'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1625'
git switch 'github-bot/gh-1625'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1625'
git switch 'github-bot/gh-1625'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1625'
git switch 'main'
git merge --squash 'github-bot/gh-1625'
git switch 'main'
git merge --ff-only 'github-bot/gh-1625'
git switch 'main'
git merge 'github-bot/gh-1625'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.