-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in subtyping/method lookup that causes unreacheable reached #53366
Comments
Do you have an MWE?
This indicates that Julia produced invalid IR at some point. |
I spent some time on this with @gbaraldi and we were able to find the broken IR and also narrow the problem down further. He should also be able to reproduce the error. Over the last few days, we found that the PackageCompiler step for our system occasionally segfaults with no stack trace. Trying this with a debug build of Julia 1.10.1 with LLVM assertions on reveals many such invalid IR errors:
This has blocked our plan to upgrade to Julia 1.10.1 this week. :( |
Cc: @KristofferC whom @Drvi had pinged about this, and @Keno, who added this error report. |
Do you have some IR or an MWE? There's still no code attached to this issue... |
Shared privately. Edited to add: sorry for the brevity here; there's more discussion on Slack. To summarize, we have not yet been able to reduce the code that triggers this error enough to share it here -- the "MWE" still contains a bunch of proprietary code. However, @gbaraldi is able to reproduce, and hopefully the problem will be tracked down quickly! |
So me and @topolarity reduced this to function flush!(sc::Threads.Condition)
@lock sc begin
try
if Core.Compiler.inferencebarrier(true)
return nothing
end
return nothing
finally
end
end
end
code_typed(flush!, (Threads.Condition,)) Note that this does not fail if you do a manual macro expansion. It also does not fail on master, so somewhere along the line we fixed this. |
Awesome! Thanks for that! Is the issue present on 1.9 as well? Can you see from the code that's being generated, even though the assertion isn't present in 1.9? |
The problem with the bad ϕ-nodes has been resolved, but this issue persists unfortunately. |
So after @topolarity and me stared at this for way too long, this got minimized to struct Foo{T} end
struct Bar{T} end
struct Baz{T} end
struct Lala{T} end
function swap!(pg::Foo{T}, page::Bar{Baz{T}}) where T
return nothing
end
TT1 = Tuple{
typeof(swap!),
Foo{Lala{T}} where T,
Bar{T} where T<:Baz
}
A = Foo{Lala{T}} where T
T = TypeVar(:T, UnionAll(A.var, Baz{A.var}))
B = UnionAll(T, Bar{T})
TT2 = Tuple{typeof(swap!), A, B}
@assert TT1 == TT2
@assert TT1 === TT2
matches1 = Base._methods_by_ftype(TT1, nothing, -1, ccall(:jl_get_world_counter, UInt, ())) # 1 match
matches2 = Base._methods_by_ftype(TT2, nothing, -1, ccall(:jl_get_world_counter, UInt, ())) # 0 matches
@show matches1 matches2
This is probably a bug in subtyping somewhere. Note that TT1 is considered egal and isequal to TT2 but they behave differently |
Either that or it's illegal to construct a type with a shared TypeVar like this, in which case the bug is that we ended up doing that somewhere in inference |
Lines 3059 to 3075 in 2b95956
An easy fix is fusing unalias_unionall here.
|
This is a partial back-port of #50924, where we discovered that the optimizer would ignore: 1. must-throw `%XX = SlotNumber(_)` statements 2. must-throw `goto #bb if not %x` statements This is mostly harmless, except that in the case of (1) we can accidentally fall through the statically deleted (`Const()`-wrapped) code from inference and end up observing a control-flow edge that never existed. If the spurious edge is to a catch block, then the edge is invalid semantically and breaks our SSA conversion. This one-line change fixes (1) but not (2), which is enough for IR validity. Resolves part of #53366.
…53512) This is a partial back-port of JuliaLang#50924, where we discovered that the optimizer would ignore: 1. must-throw `%XX = SlotNumber(_)` statements 2. must-throw `goto #bb if not %x` statements This is mostly harmless, except that in the case of (1) we can accidentally fall through the statically deleted (`Const()`-wrapped) code from inference and end up observing a control-flow edge that never existed. If the spurious edge is to a catch block, then the edge is invalid semantically and breaks our SSA conversion. This one-line change fixes (1) but not (2), which is enough for IR validity. Resolves part of JuliaLang#53366. (cherry picked from commit 035d17a)
Testing with Julia 1.10.1 + some patches, we see:
@Drvi then ran this test with a debug build of Julia and got:
We will share the entire error separately.
The text was updated successfully, but these errors were encountered: