-
-
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
Stuck compiling function #32167
Comments
Thanks for the nice reproducer repo. When I run it on master it runs for 36 seconds, ending with this output:
|
It seems at some point my timeout was too short and I simplified too much. I have bisected when I started to simplify too much and rolled back the master branch to a point where it is still failing. With MOIStuck master you should now have:
|
The bug seems to affect MathOptInterface v0.9 (no idea whether earlier versions of MOI are also affected) with Julia v1.2.0-rc3. |
Bump. This issue is now blocking the release of JuMP 0.20 because we're experiencing the hanging pretty consistently on Julia 1.2 (e.g., https://travis-ci.org/JuliaOpt/JuMP.jl/jobs/574225647). |
I reduced the hanging tests of JuMP and MOI into the following: using MathOptInterface
const MOI = MathOptInterface
MOI.Utilities.@model(Model, (), (), (), (), (), (), (), ())
MOI.supports_constraint(::Model{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.GreaterThan{T}}) where {T} = false
MOI.supports_constraint(::Model{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.LessThan{T}}) where {T} = false
model = MOI.Bridges.LazyBridgeOptimizer(Model{Float64}())
set = MOI.LessThan(1.0)
println("Calling")
MOI.add_constrained_variable(model, set)
println("Done") With Julia master and MOI v0.9, the compiler hangs while compiling |
I believe we have a temporary fix for this: jump-dev/MathOptInterface.jl#834 We needed to define two fallback methods. The weird thing is, these methods will never be called. (The errors are never triggered, if you add a print, it's never printed, and codecov is 0%.) A common pattern in the code is struct X end
foo_supported(::X) = true
foo(::X) = 1
struct Y end
foo_supported(::Y) = false
bar(::Any) = 2
function main(x)
if foo_supported(x)
return foo(x)
else
return bar(x)
end
end The fix is equivalent to defining foo(::Y) = error("foo not defined for Y") But it seems that this is just a MethodError... I haven't managed to find a simple reproducible example that doesn't require Weirder still, if you I'm a little lost with what is going on, so the best argument I can come up with is that the compiler "speculatively compiles" the branch that we know we will not take at run-time, and that for some reason it doesn't trigger a MethodError but goes down some rabbit hole. I'd appreciate any compiler team insight. Also: Julia 1.2 is significantly slower than 1.1: https://travis-ci.org/JuliaOpt/MathOptInterface.jl/builds/575028355?utm_source=github_status&utm_medium=notification |
Seems like an old issue. Open a new one if you come across problems again. |
The Julia compiler seems to get stuck when compiling the MathOptInterface
add_constraint
.I have added a print inside the function and it is never called which suggests that it's the compiler itself that gets in an infinite loop.
The bug occurs in Julia v1.0, Julia v1.1 and Julia master
To reproduce it, use https://github.com/blegat/MOIStuck
The text was updated successfully, but these errors were encountered: