Skip to content

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

Merged
theaustinayers merged 1 commit into
xcl-dev:mainfrom
theaustinayers:dstorage-late-page-array
Nov 23, 2026
Merged

theaustinayers merged 1 commit into
xcl-dev:mainfrom
theaustinayers:dstorage-late-page-array

Conversation

@theaustinayers

Copy link
Copy Markdown
Collaborator

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.

… read at the request's turn

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)
@mastrr9

mastrr9 commented Nov 23, 2026

Copy link
Copy Markdown

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)

@theaustinayers
theaustinayers merged commit 4017f8f into xcl-dev:main Nov 23, 2026
2 checks passed
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 23, 2026
The fork, rebuilt on current upstream main with only what upstream does not have: the launcher's folder picker, click-to-capture mouse handling with F8 and Page Up / Page Down, a heap per DXC compile thread, the limit on waits for pipelines still being built, the installer, build.ps1, BUILDING.md, the release workflow and the README. Everything else the fork carried is in upstream now (ivall#195 in parts, ivall#211, ivall#244, ivall#252, ivall#283, ivall#289) or was a diagnostic.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
…fallbacks

Incorporate targeted upstream fixes from ivall/xcl PRs and local diagnostics
to resolve world-loading E_ACCESS_VIOLATION streaming errors, fence monitor
deadlocks, and mesh/compute PSO visibility:

- DirectStorage (ivall/xcl PR xcl-dev#549; relates to xcl-dev#289, xcl-dev#476, xcl-dev#1164):
  * crates/xcl/src/hle/dstorage.rs: Add Pending::late and refill_late_pages()
    so queues with 0 entries in destination physical-page arrays do not
    auto-submit at half capacity before the title calls Submit() and fills
    the page entries. Add unit test
    a_late_page_array_holds_a_half_full_queue_until_the_titles_submit.
  * Ensure lazy physical pages via kernelx::lazy::ensure() in
    snapshot_page_array() and before re-reading stale destination page tables
    on execute() failure, logging failing snapshot/live entries (adds test
    dest_physical_pages_rereads_stale_snapshot).

- D3D12.X fences (ivall/xcl PR xcl-dev#1297):
  * crates/xcl/src/hle/d3d12x/fence_x.rs: Track all intermediate queued signal
    values in Fence::pending (BTreeSet<u64>) before completed_value_address()
    creates the cell, initialize the cell from GetCompletedValue() before
    publishing, and arm all pending values > initial so *cell cannot remain
    stale at 0 and deadlock callers waiting on intermediate fence values.
    Adds test intermediate_signal_queued_before_completed_value_address_updates_cell.

- D3D12.X PSOs (ivall/xcl PR xcl-dev#1300 / xcl-dev#1035 and PR xcl-dev#1298):
  * crates/xcl/src/hle/d3d12x/real.rs: Log driver rejections of translated
    compute PSOs (hr, DXIL byte size, elapsed compile ms) directly via
    xlog_warn! so refusals are not masked after note_translation_error's
    40-reason limit is consumed (PR xcl-dev#1300).
  * Update fallback_stream() to handle subobject types 24/25 (AS/MS) so
    mesh pipelines with MS in slot 24 rewrite cleanly with stand-in mesh
    shaders instead of invalid null AS payloads (PR xcl-dev#1298).

Assisted-by: Antigravity (Gemini 4 Neon)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
…xcl-dev#476)

A destination page array entry that is 0 at EnqueueRequest is read again
at the request's turn (xcl-dev#289). That read checked `readable()` and then
dereferenced the title's memory: an array the title unmapped between the
two faulted in the xcl-dstorage worker and ended the process. It now reads
with `read_own` (ReadProcessMemory), as the snapshot at enqueue already
does: the request fails with E_ACCESS_VIOLATION instead.

An array the title frees and reuses before the request's turn cannot be
told from a late fill; the title keeps it until the request is done, as
the comment now says.

The test runs 20000 requests with a deferred entry while another thread
decommits and recommits the array's page: before, the test process ended
with 0xc0000005 (5 of 5 runs); after, it passes (10 of 10).

Fixes xcl-dev#476

Assisted-by: Claude Code (Claude Opus 5.5)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
A retail title enqueues requests whose destination page array has an
entry of 0 and fills that entry after EnqueueRequest, before its own
Submit. xcl-dev#289 reads such an entry again at the request's turn, but a
half-full queue submits by itself, so during the title's loading bursts
the worker reaches the request before the title has filled the entry:
the reread still sees 0 and the request fails with E_ACCESS_VIOLATION
(0x89240009). Logged on a local build: every refused request had a
one-entry array still holding 0 at its turn.

Now a queue holding such a request does not submit by itself; the
title's Submit reads the missing entries again on the title's own
thread (through ReadProcessMemory, as at enqueue), where the array is
still the title's - which also narrows the window xcl-dev#476 describes. An
entry still 0 then is read again at the request's turn, as before.

Test: a capacity-2 queue does not run a request with a missing page
before Submit, and the request lands once the title fills the entry and
submits; it fails without the change.

Assisted-by: Claude Code (Claude Opus 5.5)

Claude-Session: https://claude.ai/code/session_01SEW8zXNUmMq1tRUZpstWXS
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
A retail title keeps its destination page lists in slots of its own
table and writes a slot's pages after EnqueueRequest. At enqueue such a
slot can still name the pages of the slot's previous request, and the
snapshot taken then is what execute() wrote to (xcl-dev#289 rereads only the
entries that are 0). Over 16 000 requests a run were written into pages
the title had since reused: its objects got garbage pointers and it
crashed about 20 s into world loading; when the old pages were freed,
the request failed with E_ACCESS_VIOLATION.

The console reads the list when it runs the request. execute() now
reads it again (through read_own, as the snapshot) and takes it when it
differs and every page in it is allocated (kernelx::physical_pages_live);
otherwise the snapshot stays, so arrays on the stack that were
overwritten since still work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
theaustinayers pushed a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
A retail title keeps its destination page lists in slots of its own
table and writes a slot's pages after EnqueueRequest. At enqueue such a
slot can still name the pages of the slot's previous request, and the
snapshot taken then is what execute() wrote to (xcl-dev#289 rereads only the
entries that are 0). Over 16 000 requests a run were written into pages
the title had since reused: its objects got garbage pointers and it
crashed about 20 s into world loading; when the old pages were freed,
the request failed with E_ACCESS_VIOLATION.

The console reads the list when it runs the request. execute() now
reads it again (through read_own, as the snapshot) and takes it when it
differs and every page in it is allocated (kernelx::physical_pages_live);
otherwise the snapshot stays, so arrays on the stack that were
overwritten since still work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
mgrein added a commit to mgrein/xcl that referenced this pull request Nov 25, 2026
A retail title keeps its destination page lists in slots of its own
table and writes a slot's pages after EnqueueRequest. At enqueue such a
slot can still name the pages of the slot's previous request, and the
snapshot taken then is what execute() wrote to (xcl-dev#289 rereads only the
entries that are 0). Over 16 000 requests a run were written into pages
the title had since reused: its objects got garbage pointers and it
crashed about 20 s into world loading; when the old pages were freed,
the request failed with E_ACCESS_VIOLATION.

The console reads the list when it runs the request. execute() now
reads it again (through read_own, as the snapshot) and takes it when it
differs and every page in it is allocated (kernelx::physical_pages_live).
A list that was on the enqueuing thread's stack keeps the snapshot: that
memory is reused once the call returns, and a page ID written there
since can belong to another live allocation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants