DirectStorage: a destination page array entry that is 0 at enqueue is read at the request's turn #289

Manually merged
github merged 1 commit from gh-pr/289/head into gh-pr/289/base 2026-11-26 04:18:52 +00:00
Owner

@⁠theaustinayers on GitHub · 2026-11-23 22:28 UTC · original
theaustinayers:dstorage-late-page-array → main · +87 −0 · 1 files · 1 commits · merged 2026-11-23 22:54 UTC

A title that keeps its DirectStorage destination page arrays in its own tables, and fills an entry after EnqueueRequest, had those requests refused with E_ACCESS_VIOLATION (0x89240009): the array is snapshotted at enqueue, the snapshot held page number 0, and write_physical_pages refuses a page that is not live. With this change an entry that is 0 in the snapshot is read again when the request runs. No issue is open for it; I searched open and closed PRs for "page array", "DestinationPageArray" and "physical pages DirectStorage" and found none covering it.

Reproduced on main (9ab7d76): a retail title, launched with scripts/smoke.ps1 -Game <folder> (XCL_NETWORK=0, 60 s, no input), reaches its first screen (an account prompt) and starts streaming in the background. In that run the activity lines add up to 28,298 DirectStorage requests, 537 failed, and the log has DirectStorage: a request failed (0x89240009): 65536 bytes from … for texture pool files. With extra logging on a local build, each refused request had options 0x200001 (zlib, destination is physical pages), a one-entry page array holding 0 at enqueue, and the same address holding a live page number (for example 0x80f50) by the time the request ran.

What is in it

  • crates/xcl/src/hle/dstorage.rs, execute: when the enqueue-time snapshot of the destination page array contains a 0, those entries are read again from the title's array; entries that had a page keep the snapshot's value, so an array passed on the stack and overwritten after enqueue behaves as before (the existing physical_page_destinations_and_sources test still covers that).
  • Unit test a_destination_page_filled_in_after_enqueue: an array whose second entry is 0 at enqueue and gets its page before Submit; the data must land across both pages, and an array still 0 at the request's turn must still fail with E_ACCESS_VIOLATION. It fails without the change (S_OK expected, 0x89240009 returned) and passes with it.

Tested

  • Ryzen 9 9950X3D, NVIDIA GeForce RTX 5090 (driver 32.0.16.2114), Windows 11 Pro 26300, Rust 1.100.0. The GPU tests ran on the RTX 5090 (D3D12.X: backend 'real' – NVIDIA GeForce RTX 5090).
  • cargo build --workspace then cargo test --workspace -- --test-threads=4 on d0b6079 (debug): 651 passed, 0 failed, 40 ignored (lib 612 / 0 / 20).
  • SKIPPED on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64).
  • The retail title, same command as above, on d0b6079: 24,067 DirectStorage requests, 157 failed, no 0x89240009 line in the log (main: 28,298 / 537). I did not break the remaining 157 down by code in this run. On a longer run of a local build with the same change and a counter (170 s into streaming): 16,384 requests found their page at their turn, 2,227 still had 0 and were refused.

Regression run

The gpu: line is the first Win32_VideoController on this PC (the CPU's integrated graphics); XCL ran on the RTX 5090 in both runs. The blocks are as the script wrote them.

main:

xcl-smoke v1
commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa
gpu: AMD Radeon(TM) Graphics
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1042 (PresentX 1042)
presents per 2 s (last 3): 37 2 21
device removals: 0
crashes: 0
peak commit: 19152 MB

this PR's head:

xcl-smoke v1
commit: d0b6079c404da7865fc8fe25e783e132670e1534
gpu: AMD Radeon(TM) Graphics
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1123 (PresentX 1123)
presents per 2 s (last 3): 25 60 60
device removals: 0
crashes: 0
peak commit: 16944 MB

Not tested

  • AMD GPUs, and any title other than this one.
  • Whether the title's picture changes: at 60 s it is still on its first screen in both runs, so I have no frame capture that shows a difference. The change is visible in the request counts only.
  • Why 2,227 entries were still 0 at their request's turn in the longer run (cancelled streams, or filled later still). Those requests fail exactly as before.
  • A source page array (SourceIsPhysicalPages) with a 0 entry: not changed.

AI use

  • Claude Code with Claude Fable 5.2: found the cause from the logs, wrote the change, the test and this description, and ran the commands above on my machine.
**@⁠theaustinayers** on GitHub · 2026-11-23 22:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/289) `theaustinayers:dstorage-late-page-array` → `main` · +87 −0 · 1 files · 1 commits · merged 2026-11-23 22:54 UTC A title that keeps its DirectStorage destination page arrays in its own tables, and fills an entry after `EnqueueRequest`, had those requests refused with `E_ACCESS_VIOLATION` (0x89240009): the array is snapshotted at enqueue, the snapshot held page number 0, and `write_physical_pages` refuses a page that is not live. With this change an entry that is 0 in the snapshot is read again when the request runs. No issue is open for it; I searched open and closed PRs for "page array", "DestinationPageArray" and "physical pages DirectStorage" and found none covering it. **Reproduced on main** (`9ab7d76`): a retail title, launched with `scripts/smoke.ps1 -Game <folder>` (`XCL_NETWORK=0`, 60 s, no input), reaches its first screen (an account prompt) and starts streaming in the background. In that run the activity lines add up to 28,298 DirectStorage requests, 537 failed, and the log has `DirectStorage: a request failed (0x89240009): 65536 bytes from …` for texture pool files. With extra logging on a local build, each refused request had `options 0x200001` (zlib, destination is physical pages), a one-entry page array holding `0` at enqueue, and the same address holding a live page number (for example `0x80f50`) by the time the request ran. **What is in it** - `crates/xcl/src/hle/dstorage.rs`, `execute`: when the enqueue-time snapshot of the destination page array contains a 0, those entries are read again from the title's array; entries that had a page keep the snapshot's value, so an array passed on the stack and overwritten after enqueue behaves as before (the existing `physical_page_destinations_and_sources` test still covers that). - Unit test `a_destination_page_filled_in_after_enqueue`: an array whose second entry is 0 at enqueue and gets its page before `Submit`; the data must land across both pages, and an array still 0 at the request's turn must still fail with `E_ACCESS_VIOLATION`. It fails without the change (`S_OK` expected, 0x89240009 returned) and passes with it. **Tested** - Ryzen 9 9950X3D, NVIDIA GeForce RTX 5090 (driver 32.0.16.2114), Windows 11 Pro 26300, Rust 1.100.0. The GPU tests ran on the RTX 5090 (`D3D12.X: backend 'real' – NVIDIA GeForce RTX 5090`). - `cargo build --workspace` then `cargo test --workspace -- --test-threads=4` on `d0b6079` (debug): 651 passed, 0 failed, 40 ignored (lib 612 / 0 / 20). - SKIPPED on this adapter: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64). - The retail title, same command as above, on `d0b6079`: 24,067 DirectStorage requests, 157 failed, no 0x89240009 line in the log (main: 28,298 / 537). I did not break the remaining 157 down by code in this run. On a longer run of a local build with the same change and a counter (170 s into streaming): 16,384 requests found their page at their turn, 2,227 still had 0 and were refused. **Regression run** The `gpu:` line is the first `Win32_VideoController` on this PC (the CPU's integrated graphics); XCL ran on the RTX 5090 in both runs. The blocks are as the script wrote them. main: ``` xcl-smoke v1 commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa gpu: AMD Radeon(TM) Graphics title: NYCMain seconds: 60 exit: 0x0 frames shown: 1042 (PresentX 1042) presents per 2 s (last 3): 37 2 21 device removals: 0 crashes: 0 peak commit: 19152 MB ``` this PR's head: ``` xcl-smoke v1 commit: d0b6079c404da7865fc8fe25e783e132670e1534 gpu: AMD Radeon(TM) Graphics title: NYCMain seconds: 60 exit: 0x0 frames shown: 1123 (PresentX 1123) presents per 2 s (last 3): 25 60 60 device removals: 0 crashes: 0 peak commit: 16944 MB ``` **Not tested** - AMD GPUs, and any title other than this one. - Whether the title's picture changes: at 60 s it is still on its first screen in both runs, so I have no frame capture that shows a difference. The change is visible in the request counts only. - Why 2,227 entries were still 0 at their request's turn in the longer run (cancelled streams, or filled later still). Those requests fail exactly as before. - A source page array (`SourceIsPhysicalPages`) with a 0 entry: not changed. **AI use** - Claude Code with Claude Fable 5.2: found the cause from the logs, wrote the change, the test and this description, and ran the commands above on my machine.
A retail title keeps its destination page arrays in its own tables and fills an entry after EnqueueRequest. The array is snapshotted at enqueue (titles also pass it on the stack), so such a request wrote to page 0 and was refused with E_ACCESS_VIOLATION: over 8,000 of them in the first 100 s of the title's streaming, and what they carried never arrived. An entry that is 0 in the snapshot (no page has that number) is read again when the request runs; entries that had a page keep the snapshot's.

Measured on the title (RTX 5090, 170 s): 16,384 such requests found their page at their turn, 2,227 still had 0 and are refused as before.

Assisted-by: Claude Code (Claude Fable 5.2)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:50 +00:00
github manually merged commit d0b6079c40 into gh-pr/289/base 2026-11-26 04:18:52 +00:00
Author
Owner

@⁠mastrr9 on GitHub · 2026-11-23 22:52 UTC · original

Independent static code audit of d0b6079c4 (code inspection only — cargo test not run on macOS; no game files):

Summary: Looks clean and well-targeted

  • Only re-reads entries that were 0 in the enqueue snapshot (preserving stack-allocated arrays that already held live page numbers at EnqueueRequest), checks readable(r.destination as usize, std::mem::size_of_val(pages)) before reading, and leaves entries still 0 rejected by write_physical_pages.

Minor edge-case notes

  1. Concurrent write vs non-atomic read (dstorage.rs:835): (r.destination as *const usize).add(k).read_unaligned() runs on the worker thread; if a title fills a slot concurrently after Submit() without prior synchronization, an atomic Acquire load (when pointer-aligned) avoids a Rust data race.
  2. Stack-allocated array with an intentional 0: If a caller passes a stack array containing a 0 entry and returns before execute runs, readable(r.destination, ...) can still be true on the live thread stack and read unrelated stack words (low risk since write_physical_pages still rejects non-live page numbers, just worth keeping in mind).

(AI-assisted)

**@⁠mastrr9** on GitHub · 2026-11-23 22:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/289#issuecomment-7116287835) Independent static code audit of `d0b6079c4` (code inspection only — `cargo test` not run on macOS; no game files): ### Summary: Looks clean and well-targeted - Only re-reads entries that were `0` in the enqueue snapshot (preserving stack-allocated arrays that already held live page numbers at `EnqueueRequest`), checks `readable(r.destination as usize, std::mem::size_of_val(pages))` before reading, and leaves entries still `0` rejected by `write_physical_pages`. ### Minor edge-case notes 1. **Concurrent write vs non-atomic read (`dstorage.rs:835`):** `(r.destination as *const usize).add(k).read_unaligned()` runs on the worker thread; if a title fills a slot concurrently after `Submit()` without prior synchronization, an atomic `Acquire` load (when pointer-aligned) avoids a Rust data race. 2. **Stack-allocated array with an intentional `0`:** If a caller passes a stack array containing a `0` entry and returns before `execute` runs, `readable(r.destination, ...)` can still be true on the live thread stack and read unrelated stack words (low risk since `write_physical_pages` still rejects non-live page numbers, just worth keeping in mind). *(AI-assisted)*
This discussion has been locked. Commenting is limited to contributors.
No description provided.