Repository navigation
D3D12.X: pipeline library blob has a readable dword after its end - #2859
bobosneefdev wants to merge 1 commit into
Conversation
|
Same card, different driver. On an RX 6800 with driver 32.0.21045.5002 (yours is 32.0.21045.29003), a pipeline library that ends 2 bytes before a page boundary does not crash without the fix. Both builds open it as a file mapping and use it. This fills in one line of Not tested ("Other AMD driver versions"): the read past the end, or the fault from it, seems to depend on the driver version. The fix does no harm on this driver either. Repro (retail title, release builds,
So on this driver the 4-byte read past the view, if it happens at all, does not fault. One run per remainder: I did not try 4093, 4095 or 0 mod 4096. Small note on the log. With the fix, a file in the copy path still logs Diff review. I read the whole diff. The length check Tested
Not tested: the crash itself (it does not reproduce on this driver); the AI use: Claude Code (Claude Opus 5.5) read the diff, built the trees, made the padded library, ran the tests and game runs, and wrote this comment. Every number comes from those runs on the hardware above. |
AMD's driver reads a dword at blob + length in CreatePipelineLibrary (amdxc64.dll+0x176cd5, `cmp dword ptr [r14], eax` with r14 = the view's address + the file's length). MappedBlob hands it a file mapping, which ends with the file's last page: a file that ends less than 4 bytes before a page boundary has that dword in the unmapped page after it, and the process dies at startup with 0xc0000005 until the file is removed. Seen on an RX 6800 (driver 32.0.21045.29003) with two libraries, both of a length of 4094 mod 4096 (1933310 and 3252222 bytes); the faulting address was the first byte after the view in every one of 3 starts. Such a file (4 lengths in 4096) is now read into memory with 4 zero bytes after it instead of being mapped. With the fix the 1933310-byte library opens and serves pipelines. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
83b95c4 to
78795c7
Compare
|
Thanks for the run on 32.0.21045.5002 and for reading the diff. Good to know the fault depends on the driver version; I will add your result to the description. The log note is fixed in Written with Claude Code (Claude Fable 5.2). |
|
Ran the pipeline-library blob tests at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. All four tests pass, including Not tested: the AMD AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
On AMD, XCL can crash at every start with
0xc0000005inamdxc64.dll+0x176cd5until the saved pipeline library is deleted. The driver reads a dword at blob + length inCreatePipelineLibrary(cmp dword ptr [r14], eax, withr14= the view's address + the file's length).MappedBlobhands it a file mapping, which ends with the file's last page, so a file that ends less than 4 bytes before a page boundary has that dword in the unmapped page after it.Seen with two libraries, 1933310 and 3252222 bytes, both 4094 mod 4096. In 3 of 3 crashing starts the faulting address was the first byte after the view. Such a file (4 lengths in 4096) is now read into memory with 4 zero bytes after it instead of being mapped.
This corrects my earlier reading in #2619, where I put the crash down to the memory-window layout.
What is in it
crates/xcl/src/hle/d3d12x/pso_library.rs:MappedBlob::openreads a file of such a length into memory with room after it; unit testmapped_blob_has_a_readable_dword_after_its_end(fails without the fix).Tested
cargo test --release -p xcl --lib pso_library: 4 passed, 0 failed. With the new branch disabled, the new test fails.cargo test --workspace -- --test-threads=4(debug) on this PR's head78795c74: 1642 passed, 12 failed, 27 ignored. On the unmodified base71b8e6e0: 1640 passed, 13 failed, 27 ignored. All 12 that fail here also fail on the base; none is inpso_library.rs.SKIPPED:gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu, 4 forms (f16 arithmetic and f16 packed, wave32 and wave64, per-lane form: refused as unsupported).c32c91a3plus local logging: the 1933310-byte library that crashed 3 starts opened, served over 1000 pipelines, and 7 newer generations were saved.Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 120, same title, same machine,XCL_PREPARE=0in the environment for both.main(e120925e):This PR's head (
78795c74):mainrun is one120925e, the commit before the tip. On the tip8b957becthe pre-launch shader preparation (xcl run: prepare shaders in the game window before title execution #2555) stopped at 23097 of 26503 records for over 26 minutes with four threads busy inamdxc64.dll, andmainhas no switch to leave it out, so no run of the tip finished.XCL_PREPARE=0leaves that preparation out on this PR's build;e120925epredates it and does not read the variable.Not tested
c32c91a3with local logging in the tree, not on this exact head.AI use
🤖 Generated with Claude Code