recompiler: NVIDIA's shader compiler crashes (SIGILL) on an always-true unordered f32 compare against an infinity; agc_driver_f32_compare_constant fails on main #3355

Closed
opened 2026-10-11 08:39:57 +00:00 by fma-rc · 2 comments
fma-rc commented 2026-10-11 08:39:57 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-11T08:39:57Z.


On main 7b5214d4 agc_driver_f32_compare_constant dies with SIGILL on Linux with an RTX 5080 (NVIDIA 615.78.08), 4 of 4 runs, and passes on RADV (Radeon 610M). The ud2 is in the driver's shader compiler (libnvidia-gpucomp.so, called from vkCreateComputePipelines in VulkanDevice::dispatch).

The fold in #2408 is not the cause, the test is just the first to compare against +inf with ngt / nlt. With CompareInstructions.cpp put back to 42692dee^ the test still crashes, and it passes on NVIDIA once the 0x7f800000 constant is masked out. Of the 24 compares against +inf exactly two crash, each alone in a shader: v_cmp_ngt_f32 x, +inf and v_cmp_nlt_f32 +inf, x, which become OpFUnordLessThanEqual %bool %x %float_0x1p_128.

A hand-written compute module with only OpCapability Shader and no float-controls mode (load a uint, OpBitcast to float, the compare, OpSelect, store) reproduces it. spirv-val --target-env vulkan1.3 accepts every variant.

compare RTX 5080
OpFUnordLessThanEqual x, +inf SIGILL
OpFUnordGreaterThanEqual x, -inf SIGILL
OpFUnordGreaterThanEqual +inf, x SIGILL
OpFUnordLessThanEqual -inf, x SIGILL
OpFOrdLessThanEqual x, +inf passes
OpFUnordLessThan x, +inf passes
OpFUnordLessThanEqual x, FLT_MAX passes
OpFUnordLessThanEqual x, -inf passes

So the driver crashes on an unordered <= / >= against an infinity that is true for every input, and any guest shader with that compare would take the process down at pipeline creation on this driver. Not run for this table: other driver versions, Windows, f64, vector operands. Later runs: an f16 compare against half infinity and an f32 compare against an infinity computed in the shader (FLT_MAX + FLT_MAX) crash the same way, so replacing only immediate infinities is not enough.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5799475953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3355). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-11T08:39:57Z. --- On `main` 7b5214d4 `agc_driver_f32_compare_constant` dies with SIGILL on Linux with an RTX 5080 (NVIDIA 615.78.08), 4 of 4 runs, and passes on RADV (Radeon 610M). The `ud2` is in the driver's shader compiler (`libnvidia-gpucomp.so`, called from `vkCreateComputePipelines` in `VulkanDevice::dispatch`). The fold in #2408 is not the cause, the test is just the first to compare against +inf with `ngt` / `nlt`. With `CompareInstructions.cpp` put back to 42692dee^ the test still crashes, and it passes on NVIDIA once the `0x7f800000` constant is masked out. Of the 24 compares against +inf exactly two crash, each alone in a shader: `v_cmp_ngt_f32 x, +inf` and `v_cmp_nlt_f32 +inf, x`, which become `OpFUnordLessThanEqual %bool %x %float_0x1p_128`. A hand-written compute module with only `OpCapability Shader` and no float-controls mode (load a uint, `OpBitcast` to float, the compare, `OpSelect`, store) reproduces it. `spirv-val --target-env vulkan1.3` accepts every variant. | compare | RTX 5080 | |---|---| | `OpFUnordLessThanEqual x, +inf` | SIGILL | | `OpFUnordGreaterThanEqual x, -inf` | SIGILL | | `OpFUnordGreaterThanEqual +inf, x` | SIGILL | | `OpFUnordLessThanEqual -inf, x` | SIGILL | | `OpFOrdLessThanEqual x, +inf` | passes | | `OpFUnordLessThan x, +inf` | passes | | `OpFUnordLessThanEqual x, FLT_MAX` | passes | | `OpFUnordLessThanEqual x, -inf` | passes | So the driver crashes on an unordered `<=` / `>=` against an infinity that is true for every input, and any guest shader with that compare would take the process down at pipeline creation on this driver. Not run for this table: other driver versions, Windows, f64, vector operands. Later runs: an f16 compare against half infinity and an f32 compare against an infinity computed in the shader (`FLT_MAX + FLT_MAX`) crash the same way, so replacing only immediate infinities is not enough.
adriadam10 commented 2026-10-11 11:55:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:55:20Z.


Fixed in part by #3441: the four always-true unordered f32 compares against an immediate infinity are folded to true, covered by vector_compare_const; computed-infinity and f16 cases are still open.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108754394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3355#issuecomment-6108754394). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:55:20Z. --- Fixed in part by #3441: the four always-true unordered f32 compares against an immediate infinity are folded to true, covered by `vector_compare_const`; computed-infinity and f16 cases are still open.
fma-rc commented 2026-10-11 15:36:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-11T15:36:12Z.


The two remaining cases pass on main a11c8f7f. #3357 changed the emitter for the unordered relations to the negated ordered form, so the f16 and computed-infinity compares no longer reach the driver as OpFUnordLessThanEqual / OpFUnordGreaterThanEqual.

Checked on the RTX 5080 with 615.78.08: a test with a half-float infinity and with FLT_MAX + FLT_MAX (https://github.com/fma-rc/AnyPS5/blob/test/float-compare-infinity/core/libs/prx/libSceAgcDriver/tests/execution/FloatCompareInfinity.cpp) passes on that commit, and so does agc_driver_f32_compare_constant. With the two emitters put back to the unordered opcodes both die with SIGILL again. Closing.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110667362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3355#issuecomment-6110667362). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-11T15:36:12Z. --- The two remaining cases pass on `main` a11c8f7f. #3357 changed the emitter for the unordered relations to the negated ordered form, so the f16 and computed-infinity compares no longer reach the driver as `OpFUnordLessThanEqual` / `OpFUnordGreaterThanEqual`. Checked on the RTX 5080 with 615.78.08: a test with a half-float infinity and with `FLT_MAX + FLT_MAX` (https://github.com/fma-rc/AnyPS5/blob/test/float-compare-infinity/core/libs/prx/libSceAgcDriver/tests/execution/FloatCompareInfinity.cpp) passes on that commit, and so does `agc_driver_f32_compare_constant`. With the two emitters put back to the unordered opcodes both die with SIGILL again. Closing.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#3355
No description provided.