Repository navigation
Avoid an inference cycle between the exception runtime and throw overlays - #3413
Merged
Merged
Conversation
Contributor
CUDA.jl BenchmarksDetails
This comment was automatically generated by workflow using github-action-benchmark. |
…lays
`setproperty!(::ExceptionInfo, sym, value)` is also inferred without a
constant `sym`, where the `:status` and `:output_lock` branches convert the
`Ptr{UInt8}` stored by `@gputhrow` to `Int32`. That checked conversion leads
back into the `throw_inexacterror` overlay, forming an inference cycle. On
Julia 1.12, inference merges the effects of all frames in such a cycle, so
the inconsistent overlays reached by the runtime tainted `Int32(::UInt64)`
and disabled concrete evaluation of any foldable code using it.
Same issue as JuliaGPU/Metal.jl#567.
maleadt
force-pushed
the
tb/consistent-runtime
branch
from
October 19, 2026 19:27
89c3018 to
88af030
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3413 +/- ##
==========================================
- Coverage 87.08% 85.14% -1.94%
==========================================
Files 192 191 -1
Lines 19543 19260 -283
==========================================
- Hits 17019 16399 -620
- Misses 2524 2861 +337 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Same class of bug as JuliaGPU/Metal.jl#567 (fixed there in JuliaGPU/Metal.jl#1070, and in OpenCL.jl by JuliaGPU/OpenCL.jl#568).
On Julia 1.12, inference forms a cycle through the exception runtime:
setproperty!is also inferred without a constantsym. In that case the:status/:output_lockbranches convert whatever value is stored toInt32. Julia 1.12 merges the effects of all frames in a cycle, and the overlays the runtime reaches (kernel_state(), the atomics,threadIdx()) are not consistent, soInt32(::UInt64)ends up withnonoverlayed = ALWAYS_FALSE. Any:foldablecode that uses it then can't be concrete-evaluated anymore.x < πhappens to avoid that conversion on CUDA, but the new test shows a foldable function that doesn't fold.The fix type-asserts those two stores instead of converting. Every setter stores an
Int32there anyway. With the fix, no cycle passes through an overlay on 1.12 or 1.13.The new
concrete evaluationcodegen test fails on 1.12 without the fix.core/codegen,core/exceptionsandcore/executionpass with it.