DirectStorage: a deferred page-array entry is reread without faulting (#476) #509
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!509
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/509/head"
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?
@requiemsnkrp on GitHub · 2026-11-24 01:07 UTC · original
requiemsnkrp:dstorage-deferred-page-array-read→main· +83 −4 · 1 files · 1 commits · merged 2026-11-25 01:06 UTCA destination page-array entry that is 0 at EnqueueRequest is read again at the request's turn (#289). That read checked
readable()and then dereferenced the title's memory. If the title unmapped the array between the two, the read faulted in thexcl-dstorageworker and ended the process. It now reads withread_own(ReadProcessMemory), as the enqueue-time snapshot already does, so the request fails withE_ACCESS_VIOLATIONinstead. Fixes #476.An array that is freed and reused before the request's turn cannot be told from a late fill. The title keeps it until the request is done; the comment now says so.
What is in it
crates/xcl/src/hle/dstorage.rs,execute: the deferred entries are read withread_own; if that read fails, the request keeps its 0 entries and fails as beforecrates/xcl/src/hle/dstorage.rs, tests:a_deferred_page_array_unmapped_under_the_worker_fails_the_requestruns 20000 requests with a deferred entry while another thread decommits and recommits the array's pageTested
main2997c9a, without the fix (5 runs,--exact): 5 ×0xc0000005 STATUS_ACCESS_VIOLATION; with the fix: 10 of 10 passed;hle::dstoragetests: 14 passedcargo test --workspace -- --test-threads=4on3724b07: 677 passed, 0 failed, 41 ignored (main2997c9aon the same machine: 676 passed, 0 failed, 41 ignored)gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareRegression run
main:
PR:
Not tested
AI use
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@brothernog on GitHub · 2026-11-24 01:42 UTC · original
Tested
3724b07on an RTX 3050 (driver 610.88), Windows 11 Home 26300, Rust 1.100.0, debug:a_deferred_page_array_unmapped_under_the_worker_fails_the_request: 5 of 5 passed. With only theexecutehunk reverted to the oldreadable()+read_unaligned, 3 of 3 runs ended in0xc0000005 STATUS_ACCESS_VIOLATION.cargo test -p xcl --lib hle::dstorage: 14 passed.cargo build --workspacethencargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.A sibling with the same check-then-read shape is in the same function. A memory source is checked with
crate::gpu::shader::readableand then copied withcopy_nonoverlappingfrom title memory on the worker thread (dstorage.rs:801-806on this head). If a title frees the source before the request's turn, that copy faults inxcl-dstoragejust like #476 did.read_ownthere would turn it intoE_ACCESS_VIOLATIONtoo, whether in this PR or in a follow-up. I didn't find an open PR that covers it.This review was AI-assisted.
@requiemsnkrp on GitHub · 2026-11-24 01:50 UTC · original
@brothernog thanks for the independent run, and for the memory-source copy: you were right. Same shape, same fault: the new test on
main508a0c7ended with0xc0000005in 5 of 5 runs before the change and passed 10 of 10 after. I kept it out of this PR (one problem per PR) and opened #561. It is branched frommainand does not depend on this one.Written with Claude Code (Claude Opus 5.5).
@MesshM on GitHub · 2026-11-24 04:21 UTC · original
Test run of
3724b07170bd2ad3f689cbcfa2006a718b4443eaon AMD RDNA4. I merged it onto currentmainf4ce27clocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 702 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 661 passed, 0 failed, 21 ignoredSKIPPED;a_deferred_page_array_unmapped_under_the_worker_fails_the_requestpasses.Review: Rereading the deferred entries with
read_own(ReadProcessMemory) instead ofreadable()+ a raw read means an array unmapped between the two no longer faults inxcl-dstorage; when the read fails the enqueue-time snapshot is used. Same pattern as #561 and #705. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@raylitebull on GitHub · 2026-11-25 00:56 UTC · original
Diff check on
3724b07:readable()+read_unaligned()withread_own()indstorage::executecleanly prevents access violations when a deferred (0) page-array entry is decommitted before the worker rereads it, anda_deferred_page_array_unmapped_under_the_worker_fails_the_requestdirectly covers the race.RX 9060 XT) and NVIDIA (RTX 3050), withPR descriptionpassing.Next step to unblock merge: Please rebase onto current
main(or push an updated commit) so CI runsBuild and test (Windows, no GPU)on the head.