Repository navigation
SPIR-V: copy late bool phi values (NVIDIA 580 crash in Astro's Playroom) - #49
Closed
pernahlebihtampan wants to merge 1 commit into
Closed
pernahlebihtampan wants to merge 1 commit into
pernahlebihtampan wants to merge 1 commit into
Conversation
NVIDIA's SPIR-V compiler (driver 580.178, libnvidia-glvkspirv.so+0x157c88) dereferences a null terminator on a bool OpPhi whose incoming values are all defined before it when one predecessor comes later in the function (a loop header's back edge). Astro's Playroom's ray-traced lighting kernel 0x1a33cd8c1711bfb3 has five such phis; the emulator closed right after the game left its menu. On those edges the phi now takes a copy made at the end of the later predecessor, which the driver has not seen yet at the phi, so the phi stays a plain bool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Has been merged and added to a release |
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.
Problem
On Linux with an RTX 3070 and NVIDIA driver 580.178.04, Astro's Playroom (PPSA01325) closes right after the game leaves its menu:
The faulting PC is inside NVIDIA's SPIR-V compiler, at
libnvidia-glvkspirv.so.580.178.04+0x157c88. It fires while a background thread builds the software RT pipeline of compute shader0x1a33cd8c1711bfb3. On Linux,CallCatchingStructuredExceptiondoes not catch faults, so the emulator exits. (On Windows the same fault would turn software RT off for the session.)Cause
From the driver disassembly: when the compiler translates a bool
OpPhiwhose incoming values are all defined before the phi (instruction results, not constants), it retypes the phi. It then inserts a conversion before the terminator of each predecessor. If a predecessor appears later in the function (a loop header's back edge), that block has not been translated yet, sogetTerminator()returns null and the compiler dereferences it.A 30-line hand-written compute shader reproduces this in a standalone Vulkan program: a loop header with
OpPhi %bool %c0 %entry %c0 %continue, where%c0is anOpULessThanin the entry block. It crashes at the same address. With a constant on one edge, or with the back-edge value defined in the continue block, it builds.In the dumped module of kernel
0x1a33cd8c1711bfb3, five bool phis match this pattern.Fix
EmitStructuredFunctionnow finds the incoming edges of bool phis whose predecessor is emitted at or after the phi's own block. On each such edge, it emits anOpCopyObjectof the value at the end of the predecessor, before the terminator, and the phi takes the copy. The driver has not seen the copy yet when it reaches the phi, so it keeps the phi a plain bool. The phi's semantics do not change, and other phis are untouched.Testing
0x1a33cd8c1711bfb3(1243 ms) and0x7d6ab87e6c984bb7(5705 ms).KYTY_RT_DUMP_DIR, function and.inlinevariants) passspirv-val --target-env vulkan1.3. A script that looks for the crash pattern finds 0 matches.0x1a33cd8c1711bfb3by stripping the copies. In the standalone harness it crashes at+0x157c88, while the fixed module gets past that point.shader_recompiler_compute_tests, etc.). Not tested: AMD/Intel, or other NVIDIA driver versions.The codegen version changes, so program caches rebuild, and the first build of each RT kernel takes a few seconds while the driver cache refills.
🤖 Generated with Claude Code