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). |
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 head83b95c4f: 1643 passed, 11 failed, 27 ignored. On the unmodified base71b8e6e0: 1640 passed, 13 failed, 27 ignored. All 11 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, 120 s,main8b957becand this PR's head). The twoxcl-smokeblocks will be pasted here when they finish.Not tested
c32c91a3with local logging in the tree, not on this exact head.AI use
🤖 Generated with Claude Code