D3D12.X: read_committed survives concurrent decommit and unmap #454
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!454
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/454/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?
@kxiserino on GitHub · 2026-11-24 00:31 UTC · original
kxiserino:fix/title-textures-read-committed-race→main· +99 −3 · 1 files · 2 commits · closed without mergingWhat is in it
std::ptr::copy_nonoverlappinginhle::d3d12x::title_textures::read_committedwithcopy_readable_rangebacked byReadProcessMemoryon the current process so concurrent physical page decommits / unmaps betweenVirtualQueryand the copy leave unmapped pages zeroed instead of raisingSTATUS_ACCESS_VIOLATION(0xC0000005).ReadProcessMemorypartial failure (ERROR_PARTIAL_COPY), advance past any confirmed bytes and retry the remainder one 4 KiB page at a time so readable leading pages before a hole are preserved even when Windows reportsread == 0.read_committed'sVirtualQueryloop (saturating_addandend <= pcheck).read_committed_skips_unmapped_holes_and_survives_concurrent_decommitcovering non-page-aligned holes, directcopy_readable_rangeover fixed holes at aligned and unaligned offsets, and a 1,000-iteration concurrent commit/decommit stress loop.Tested
32.0.16.1714, wave32-only), DXC1.9.2609.5.cargo test -p xcl --lib read_committed_skips_unmapped_holes_and_survives_concurrent_decommit: 11/11 consecutive runs passed (1,000 concurrent iterations each + fixed-hole assertions at+0,+0x7b,+0x104d).cargo test -p xcl --lib title_textures: 8 passed, 0 failed.cargo test --workspace -- --test-threads=4(lib, on base2018c67): 636 passed, 1 failed (hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory, pre-existing failure in this environment; confirmed passing on RDNA3/Blackwell by reviewers), 21 ignored; 2 GPU tests reportedSKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64andgpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.cargo test --workspace --test "*" -- --test-threads=4: 40 passed, 0 failed across all 12 integration test binaries.Regression run
Not tested
hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memoryfailed in this environment (unrelated to this PR).AI use
@PHeitor1 on GitHub · 2026-11-24 00:44 UTC · original
Tested
2018c67merged ontomain2997c9a.RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed, so the debug-layer tests run), rustc 1.100.0 MSVC, debug,
cargo test --workspace --no-fail-fast -- --test-threads=4, noXCL_SAMPLE_*.Pass: 677 passed, 0 failed, 41 ignored. SKIPPED: only the 2
no wave64tests (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware). Build clean.Run and written with Claude Code (Claude Opus 5.5).
@TheHoracio on GitHub · 2026-11-24 00:46 UTC · original
Test report on AMD RDNA3: RX 7800 XT (16 GB, wave32 and wave64), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used. The PR's own runs are all on NVIDIA, so this adds an AMD GPU with 64-lane waves.
Tested: the PR head
2018c67as it is (on its basea6f5f7a).cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored, no SKIPPED tests (the twono wave64tests run here).read_committed_skips_unmapped_holes_and_survives_concurrent_decommitpasses.xmem_virtual_query_marks_cpu_readable_memory, which failed in your environment, passes here.Not tested: a regression run on a title, a release build, the head merged onto current
main.AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above.
@kxiserino on GitHub · 2026-11-24 00:55 UTC · original
Thanks @4usphs for catching that! Fixed in
1b02162: when ReadProcessMemory fails with ERROR_PARTIAL_COPY, copy_readable_range now advances past any confirmed bytes and retries the remainder one 4 KiB page at a time so readable leading pages before a hole are preserved even when Windows returnsead == 0. Added direct fixed-hole assertions (at +0, +0x7b, +0x104d) and bumped the concurrent stress loop to 1,000 iterations (11/11 local runs passed + fresh 30s smoke run).
@PHeitor1 on GitHub · 2026-11-24 01:10 UTC · original
Retested the new head
1b02162merged ontomain2997c9aon NVIDIA: RTX 5060 Ti 8 GB (Blackwell), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300, rustc 1.100.0 MSVC, debug.cargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored. SKIPPED: only the 2no wave64tests.read_committed_skips_unmapped_holes_and_survives_concurrent_decommitalone, each run its own process: 50 of 50 passed. That is the count @4usphs used for the 2-of-50 failure on2018c67.Run and written with Claude Code (Claude Opus 5.5).
@4usphs on GitHub · 2026-11-24 00:51 UTC · original · edited 2026-11-24 07:13 UTC
An RDNA4 run, next to the RDNA3 one above. The crash is fixed, but the page skip zeroes readable pages, and the new test catches that now and then: it failed 2 of 50 runs here.
Tested:
2018c67on RX 9070 XT (RDNA4, wave64), driver 32.0.32029.2010, Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.100.0, debug.cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored, 0SKIPPED. Sincea6f5f7a,main(2997c9a) changes onlyREADME.md, so this is the same code as the merge.copy_readable_rangecall put back tocopy_nonoverlapping, the new test crashes 5 of 5 runs (0xc0000005).title_textures.rs:1705(buf[..4 * PAGE]not all0x5A). Pages 0–3 are never written after setup, so the zeros come from the skip.Why. On this Windows build, when
ReadProcessMemoryreaches an unreadable page it returnsERROR_PARTIAL_COPY(299) and usuallyread = 0, not the count up to the bad page.copy_readable_rangethen moves on one page at a time fromstart, and each retry fails until it is past the hole. The pages it stepped over stay zero.copy_readable_rangeover all 8 pages returns pages 0–3 as zero (0x4000 bytes; the same with starts at +0x7b and +0x104d). Pages 6–7 are correct.VirtualQuery(base)reports one 32-page region, so pages 0–3 are copied in the same call as the middle. With counters added locally, over 20 000 iterations of the test's loop: about 215ReadProcessMemoryfailures per run (about 50 withread > 0), and pages 0–3 came back zero in 0, 4 and 4 iterations across three runs. The 400 iterations in the test saw 0, 16 and 0 failures, so the test usually never reaches the skip at all.read = 0.One possible fix: when a read fails, copy that range one page at a time.
Not tested: smoke or a retail title, a release build, whether a title ever reads the zeroed pages.
AI use: Claude Code (Claude Opus 5.5) ran the tests and the local probes on my PC and wrote this comment. I have not reviewed the code; the measurements are from runs on my PC.
Update:
1b02162on the same RX 9070 XT (RDNA4). The fix works here.1b02162as is (basea6f5f7a),cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored, 0SKIPPED.read_committed_skips_unmapped_holes_and_survives_concurrent_decommitalone, each run its own process: 50 of 50 passed (on2018c67it was 48 of 50).copy_readable_rangebody set back to2018c67, the new test fails 10 of 10 runs attitle_textures.rs:1697,leading pages zeroed at off=0x0. So the fixed-hole check catches the bug every time, not only now and then.Overlap with #484.
mainnow has #484 (27c3571, merged 03:38 UTC), which fixes the same crash in the same function a different way:copy_committed_region, which splits a failed range in two at page boundaries. This PR now conflicts withmainintitle_textures.rs. I tookmainbeaa245with #484's code, added this PR's test (the one direct call changed tocopy_committed_region(base + off, dst, len)), and ran it: 50 of 50 passed, along with #484's tworead_committedtests. So on this GPU,mainalready passes this PR's test, including the fixed hole and the 1 000-iteration stress loop.Not tested: smoke or a retail title, a release build, the full suite on
main+ this test.AI use: Claude Code (Claude Opus 5.5) ran the tests and the control on my PC and wrote this update. I have not reviewed the code.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@raylitebull on GitHub · 2026-11-24 10:42 UTC · original
Closing as a duplicate of #484, which has already been merged into
main.Pull request closed