Repository navigation
Shaders: give buffer size queries their own bounded heap handle (AMD compiler crash) - #109
Open
WHOISJARDAS wants to merge 1 commit into
Open
WHOISJARDAS wants to merge 1 commit into
WHOISJARDAS wants to merge 1 commit into
Conversation
AMD's shader compiler (driver 32.0.32029.2010, RX 9070 XT, RDNA 4) crashed building programs that read or write a buffer at an offset made from that same buffer's size: an access violation reading 0x8 at amdxc64.dll+0x861b9f while the pipeline is created, which ends the run. The title reads the last records of some buffers so, with the record count from their descriptors read as data, and the size query and the access went through one handle. The size query now gets a handle of its own, its heap index bounded by a dx.op UMin one slot below the view limit (2^26 - 1 without one), so it is never the handle the access goes through. Nothing else changes. On the RX 9070 XT: the 70 compute programs that crashed the compiler on main build their pipelines; every one of the 22,379 programs whose DXIL changes builds its pipeline (0 refused); translate and validate give the same outcome as main for all 25,889 programs. New test: emit::descriptor_tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the AMD shader compiler crash
0xc0000005atamdxc64.dll+0x861b9f("read 0x8") that ends runs when a pipeline is created, here on an RX 9070 XT and in the reports on other Radeon cards (#81, #46; upstream fxceless/victory-fork#3 and fxceless/victory-fork#120), without leaving any pass out and without skip lists.What was wrong
Some programs read a buffer's last records at an offset made from that buffer's own size: the record count comes from the descriptor read as data (
descriptor_data, lowered togetDimensions), and the read or write goes through the same descriptor. Both went through one heap handle. AMD's compiler (driver 32.0.32029.2010, RDNA 4) crashes building exactly that shape, an access through a handle at an offset computed from that handle's owngetDimensions. The DXIL is valid (the validator passes it), so this is the driver, but the shape is ours to avoid.descriptor_datanow asks the size through a handle of its own (Shader::size_handle): its heap index goes through adx.op.binaryUMin, one slot below the view limit when there is one (VIEW_LIMIT - 1), else2^26 - 1(past any host heap, below what an index made from a 32-bit address can be), so it is never the access's handle.shortcut:with a limit, an index at or past the slot below the null slot reads that slot's size where reads go to the null slot; neither holds one of the title's views.This also covers
501f0865fdf45dfd, the program #61 leaves the reuse pass out on AMD for: with this, it builds with every pass on.Tested
AMD Radeon RX 9070 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26200, Rust 1.98.1,
shaders.rpfof the title's buildb99f876b.Offline, one process per program (
VICTORY_TRANSLATE_ONLY=<hash> victory translate --validate --pipelines --jobs 1):main(90b529f)main(among them501f0865fdf45dfd)Whole archive:
translate --validate --list: the same outcome asmainfor all 25,889 programs (26,084 translated, 0 differences).39f0e9aeb156a61c, left out as the program whose compile does not finish in Works on AMD RX 9070 XT (lit opening cutscene) with three AMD-specific pipeline skips fxceless/victory-fork#3) were built as host pipelines on this card in 13 batches: 22,379 created, 0 refused, 0 crashes.In game (diag build, Series X profile, default switches, no skip list, cold shader cache; both runs also carry #108, without which
maindoes not start on this machine):0xc0000005atamdxc64.dll+0x861b9f(the last compute programs translated were072f5fe96efd27e1and501f0865fdf45dfd)mesh f5e50eb2108c425b(integer-target blending, #36)cargo test --workspace --locked: 497 passed, 0 failed, 7 ignored, including the newemit::descriptor_tests::every_lane_reads_the_last_dword_its_buffers_record_count_names, which runs on the GPU and on WARP. Without thelower.rschange its process dies on this card with0xc0000005(STATUS_ACCESS_VIOLATION); with it, it passes.-D warnings, with and without--all-features): clean.cargo xtask policy: ok.Overlap
#58 moves the same
getDimensionscall into a newLower::dimensions. Whichever lands first, the other is a small rebase: with #58 in, buffer views takesize_handleinsidedimensions. Happy to rebase this onto it.Not tested
NVIDIA (where
VIEW_LIMITis set, so theVIEW_LIMIT - 1bound is what runs) and Intel; RDNA 2/3; Linux/Wine.AI use
Claude Code (Claude Opus 5.5) reduced the crash, wrote the change and the test, and ran the offline batches. The hardware, the title copy and the runs are mine.
🤖 Generated with Claude Code