D3D12.X: a texture worker faults in detile_level on title memory that title_bytes borrowed #2841
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#2841
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@frozht on GitHub · 2026-11-26 17:34 UTC · original
A texture worker crashes in
Chain::detile_levelreading a title page that is no longer mapped.title_bytesdecided the range was readable and borrowed it, so the copy runs on raw title memory.What happened: the retail title from #505 (1.0.2.1) under Wine reached the intro cinematic, then crashed at 965.5 s:
Symbolized with
addr2lineon the same binary:+0x2eaae7<[u8]>::copy_from_slice, inlined ingpu::tiling::Chain::detile_level(dst.copy_from_slice(s))+0x696cf4hle::d3d12x::title_textures::subresources(c.detile_level(&slice, i, s))+0x13b2fetitle_textures::subresources_on::{closure}, a worker thread of the parallel pathWhy the bounds check does not help: in
subresources,slicecomes fromtitle_bytes(va + s * slice_bytes, slice_bytes). Whengpu::shader::readablesays yes,title_bytesreturnsCow::Borrowed(slice::from_raw_parts(at, len)), a view of the title's memory, not a copy.detile_level'ssrc.get(o..o + e)only checks against the slice length, so it cannot catch a page inside the range that is unmapped when the copy happens. On the other branch (read_committed) the copy would come from an ownedVecand could not fault, so this crash took the borrowed branch.So either
readableanswered yes for a range that was not all readable, or the title released or decommitted the pages between the check and the read on a worker thread. I did not determine which. The same structure is onmain(title_textures.rstitle_bytes,gpu/shader.rsreadable).Setup: RX 7900 XT 20 GB, Mesa 26.2.6 RADV, vkd3d-proton
30b0eb9b, wine-staging 11.22, Ryzen 9 5900X, 32 GB RAM, Linux 7.3, release (x86_64-pc-windows-gnu). Tree:mainb49be183+ #877, #684, #1993, #2127, plus a local probe that routes 547 named compute records to the direct DXIL translator (without it the title does not get this far on RADV). #877 changestitle_bytesunder Wine: it skips the borrowed path for ranges in a committed UMA window. Not reproduced onmainalone or on Windows. One run, so I don't know if it is deterministic.Not tested: Windows, NVIDIA, a second run, which texture it was (its VA and format were not logged).
AI use: Claude Code (Claude Opus 5.5) ran the game, symbolized the stack, read the code and wrote this; checked against the run log before posting.
@ClosetPie107 on GitHub · 2026-11-26 20:26 UTC · original
This reproduces on plain
main(8b957bec) under Proton on an RX 9070 (RADV), with the same stack.Stack. Release
xcl.exeof8b957bec. I symbolized it against a rebuild of the same commit withCARGO_PROFILE_RELEASE_DEBUG=line-tables-only. The bytes before each return address match the tested binary at the same offset.(Under
x86_64-pc-windows-gnuwith Proton, the copy is inucrtbase.dllrather thanmsvcrt.dll.)How often. In 300 s runs of the retail title (1.0.2.1), with warm caches and
XCL_TEXTURE_LEVEL_PAGES=1,XCL_PSO_WAIT_MS=50,XCL_DIRECT_DXIL=1, this crash ended:main8b957bec, at 293 s;mainandmain+ #2547 / #2581, which do not touch this code, between 165 and 293 s, always after the world start (about 100 s);main2898511and of other trees yesterday, with the sameucrtbaseread signature. I did not symbolize those builds.The faulting addresses of today's runs (e.g.
0x77730c000,0xbdc2dbe90) are ordinary title memory, above XCL's UMA windows (which start at0x400000000).With #2849 on the same
main, 6 of 6 runs went the full 300 s. Details are in the test report on #2849.Setup
experimental-11.0-20261112,vkd3d-protonmasterec207194(dxil-spirvb540c8a2) with a local patch that drops thelpVtblidentity checks ind3d12_command_allocator_from_iface/d3d12_command_list_from_iface, DXC1.9.2609.5, Rust 1.96.0, targetx86_64-pc-windows-gnu, release builds for the titleAI use: Claude Code (Claude Opus 5.5) ran the tests on this machine, symbolized the stack and wrote this comment.
@frozht on GitHub · 2026-11-26 20:49 UTC · original
Update: two open PRs already fix this. #751 (
with_title_bytes, a per-thread reused buffer) and #2849 (page-by-page copy) both stop borrowing title memory outside the coherent window. I found them after writing the same fix locally, so I'm not opening a third PR. Here is what I measured with mine, in case it helps choose between them.Recurrence and cause. The crash happened in 4 of 5 runs that got far enough, at 143, 243, 763 and 965 s, with the same stack each time. From the code:
refresh_oncere-uploads every registered texture that has written pages or is new, not only the ones in the current submit. It holds a reference to the D3D resource but nothing that keeps the title's memory alive. The title can then decommit that memory from another thread, through theVirtualFreehook for a sparse reservation or a placeholder, through plainVirtualFree, or throughsparse::free, whiletitle_bytes' borrowed view is still being read. A unit test that decommits the range afterreadable()returned true crashes the test exe with the oldtitle_bytes("wine: Unhandled page fault on read access") and passes with a fault-safe copy.Copy cost under Wine (release test exe, wine-staging 11.22, Ryzen 9 5900X, average of 20):
content_hash(old)ReadProcessMemorycall, fresh bufferReadProcessMemorycall, reused bufferReadProcessMemoryin 1 MiB steps, fresh bufferReadProcessMemoryin 1 MiB steps, reused buffermemcpySo under Wine one
ReadProcessMemorycall over a large range costs 3 to 4 times as much as the same copy in 1 MiB steps. #751 makes one whole-range call first, so on Wine it may be worth splitting that read. I did not measure this on Windows.Game runs with the fix: RX 7900 XT, Mesa 26.2.6 RADV, vkd3d-proton
30b0eb9b. Tree:mainb49be183+ #877, #684, #1993, #2127, plus a local probe that routes 547 compute records to the direct DXIL translator, plus the fix. Two runs of 1500 s each: no crash. In one run presents stopped after 204 s, and the other had no presents from 160 s to 1056 s. Runs of this tree without the fix stalled the same way, but I don't know the cause. Two runs aren't enough to say the crash is gone.Not tested: #751 and #2849 themselves; Windows.
AI use: Claude Code (Claude Opus 5.5) wrote the local fix and the test, ran the measurements and the game runs, and wrote this. I checked the numbers against the logs before posting.
@andrewDoing on GitHub · 2026-11-27 03:10 UTC · original
The two proposals for #2841 have different CPU copy costs. I built each exact head on Windows with a test-only byte counter in
read_committedand the same 256 × 256 R8 fixture. Each source held 65,536 bytes. I exercisedcontent_hash,same_as_last_upload, and, only when the hash changed,subresources. One source was ordinary readable process memory. The other was allocated from XCL’s committed coherent UMA window.4e931734snapshot bytesc1c22863snapshot bytesOn #2849, ordinary memory is copied for hashing and copied again for detiling when changed. Coherent memory is borrowed in both paths. On #2877, the hash borrows both readable sources and worker detiling copies either source. Both heads skipped unchanged content, and all four changed-source runs produced the expected 65,536 detiled bytes. Each focused test passed without a skip.
The counter measures requested CPU snapshot bytes, excluding the detiled destination and GPU uploads. This was a single-threaded helper comparison on stable memory, without a retail title, decommit, GPU dispatch or timing measurements. The result does not establish which source predominates during world loading.
AI use: OpenAI Codex with GPT-6.2 Astra adapted the fixture and ran the checks; Codex coordinated and prepared the comparison.