Skip to content
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

unreachable reached #31439

Closed
chriscoey opened this issue Mar 21, 2019 · 10 comments · Fixed by #31512
Closed

unreachable reached #31439

chriscoey opened this issue Mar 21, 2019 · 10 comments · Fixed by #31512
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch

Comments

@chriscoey
Copy link

Please see the issue on SumOfSquares.jl: jump-dev/SumOfSquares.jl#95

I tried Julia master (Version 1.2.0-DEV.518 commit 54fe55b) with --check-bounds=yes. The error occurs on (at least) Windows and Linux and did not happen in Julia 1.1.

julia> optimize!(model)
Unreachable reached at 0x7fa00e107e04

signal (4): Illegal instruction
in expression starting at REPL[6]:1
Type at /home/coey/.julia/packages/SumOfSquares/mAduI/src/sos_polynomial_bridge.jl:32
jl_fptr_trampoline at /home/coey/julia/src/gf.c:1871
jl_apply_generic at /home/coey/julia/src/gf.c:2226
add_constraints at /home/coey/.julia/packages/MathOptInterface/C3lip/src/Bridges/bridgeoptimizer.jl:338
jl_fptr_trampoline at /home/coey/julia/src/gf.c:1871
jl_apply_generic at /home/coey/julia/src/gf.c:2226
copyconstraints! at /home/coey/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:157
unknown function (ip: 0x7fa00e10291b)
jl_fptr_trampoline at /home/coey/julia/src/gf.c:1871
jl_apply_generic at /home/coey/julia/src/gf.c:2226
default_copy_to at /home/coey/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:200
#automatic_copy_to#61 at /home/coey/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:15 [inlined]
#automatic_copy_to at ./none:0 [inlined]
#copy_to#1 at /home/coey/.julia/packages/MathOptInterface/C3lip/src/Bridges/bridgeoptimizer.jl:91 [inlined]
#copy_to at ./none:0
unknown function (ip: 0x7fa00e0f73bd)
jl_fptr_trampoline at /home/coey/julia/src/gf.c:1871
jl_apply_generic at /home/coey/julia/src/gf.c:2226
attach_optimizer at /home/coey/.julia/packages/MathOptInterface/C3lip/src/Utilities/cachingoptimizer.jl:130
optimize! at /home/coey/.julia/packages/MathOptInterface/C3lip/src/Utilities/cachingoptimizer.jl:166
jl_fptr_trampoline at /home/coey/julia/src/gf.c:1871
jl_apply_generic at /home/coey/julia/src/gf.c:2226
#optimize!#77 at /home/coey/.julia/packages/JuMP/jnmGG/src/optimizer_interface.jl:132
optimize! at /home/coey/.julia/packages/JuMP/jnmGG/src/optimizer_interface.jl:105 [inlined]
optimize! at /home/coey/.julia/packages/JuMP/jnmGG/src/optimizer_interface.jl:105
jl_fptr_trampoline at /home/coey/julia/src/gf.c:1871
jl_apply_generic at /home/coey/julia/src/gf.c:2226
do_call at /home/coey/julia/src/interpreter.c:323
eval_value at /home/coey/julia/src/interpreter.c:411
eval_stmt_value at /home/coey/julia/src/interpreter.c:362 [inlined]
eval_body at /home/coey/julia/src/interpreter.c:758
jl_interpret_toplevel_thunk_callback at /home/coey/julia/src/interpreter.c:884
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fa009f1970f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /home/coey/julia/src/interpreter.c:893
jl_toplevel_eval_flex at /home/coey/julia/src/toplevel.c:797
jl_toplevel_eval_flex at /home/coey/julia/src/toplevel.c:746
jl_toplevel_eval_in at /home/coey/julia/src/toplevel.c:826
eval at ./boot.jl:327
jl_apply_generic at /home/coey/julia/src/gf.c:2226
eval_user_input at /home/coey/julia/usr/share/julia/stdlib/v1.2/REPL/src/REPL.jl:86
macro expansion at /home/coey/julia/usr/share/julia/stdlib/v1.2/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:269
jl_apply_generic at /home/coey/julia/src/gf.c:2226
jl_apply at /home/coey/julia/src/julia.h:1594 [inlined]
start_task at /home/coey/julia/src/task.c:583
unknown function (ip: 0xffffffffffffffff)
Allocations: 70883226 (Pool: 70872874; Big: 10352); GC: 160
Illegal instruction (core dumped)
@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Mar 21, 2019
@JeffBezanson JeffBezanson added this to the 1.2 milestone Mar 21, 2019
@Keno
Copy link
Member

Keno commented Mar 23, 2019

Can reproduce. Talking a look.

@Keno Keno self-assigned this Mar 23, 2019
@Keno
Copy link
Member

Keno commented Mar 24, 2019

Looking at:

mi = Cthulhu.first_method_instance(Tuple{Type{
           SumOfSquares.SOSPolynomialBridge{Float64,MathOptInterface.VectorAffineFunction{Float64},SemialgebraicSets.FullSpace,Union{SumOfSquares.GenericVariableBridge{Float64,MathOptInterface.Nonnegatives}, SumOfSquares.GenericVariableBridge{Float64,MathOptInterface.PositiveSemidefiniteConeTriangle}, SumOfSquares.GenericVariableBridge{Float64,SumOfSquares.EmptyCone}, SumOfSquares.GenericVariableBridge{Float64,SumOfSquares.PositiveSemidefinite2x2ConeTriangle}},MathOptInterface.PositiveSemidefiniteConeTriangle,MonomialBasis,Monomial{true},MonomialVector{true}}},
           MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}},
           MathOptInterface.VectorAffineFunction{Float64},
           SumOfSquares.SOSPolynomialSet{SemialgebraicSets.FullSpace,NonnegPolyInnerCone{MathOptInterface.PositiveSemidefiniteConeTriangle},MonomialBasis,Monomial{true},MonomialVector{true},Tuple{}}
       })

we see a call to

(SumOfSquares.SOSPolynomialBridge{...})(%34, %28, %44)

Where %34 is inferred as

Union{SumOfSquares.CopositiveInnerVariableBridge{_A,_B} where _B where _A, SumOfSquares.GenericVariableBridge{_A,Any} where _A, SumOfSquares.ScaledDiagonallyDominantVariableBridge{_A} where _A}

but at runtime, the value is of type

SumOfSquares.GenericVariableBridge{Float64, MathOptInterface.Nonnegatives}

which is not a subtype. Looking into where that inference result comes from.

@Keno
Copy link
Member

Keno commented Mar 24, 2019

That type comes from:

code_typed(SumOfSquares.add_variable_bridge, Tuple{Type, MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, Any})[2]

@Keno
Copy link
Member

Keno commented Mar 24, 2019

Reduced to the following intersection:

julia> TT = Tuple{typeof(SumOfSquares.add_variable_bridge), Type, MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, Any}

julia> ST = Tuple{typeof(SumOfSquares.add_variable_bridge),Type{SumOfSquares.GenericVariableBridge{T,S}},MathOptInterface.ModelLike,S} where S where T

julia> typeintersect(ST, TT)
Tuple{typeof(SumOfSquares.add_variable_bridge),Type{SumOfSquares.GenericVariableBridge{T,Any}},MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}},Any} where T

which is too narrow:

julia> IT = Tuple{typeof(SumOfSquares.add_variable_bridge),Type{SumOfSquares.GenericVariableBridge{T,S}},MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}},S} where S where T;

julia> IT <: ST
true

julia> IT <: TT
true

julia> typeintersect(ST, TT) <: IT
true

julia> IT <: typeintersect(ST, TT)
false

@Keno Keno added the types and dispatch Types, subtyping and method dispatch label Mar 24, 2019
@Keno
Copy link
Member

Keno commented Mar 24, 2019

Standalone reduction:

abstract type Bar end
struct Bar1 <: Bar end
struct Foo{T}
end
julia> typeintersect(Tuple{Type{Foo{T}},Bar,T} where T, Tuple{Type,Bar1,Any})
Tuple{Type{Foo{Any}},Bar1,Any}

julia> IT = Tuple{Type{Foo{T}},Bar1,T} where T
Tuple{Type{Foo{T}},Bar1,T} where T

julia> IT <: typeintersect(Tuple{Type{Foo{T}},Bar,T} where T, Tuple{Type,Bar1,Any})
false

julia> typeintersect(Tuple{Type{Foo{T}},Bar,T} where T, Tuple{Type,Bar1,Any}) <: IT
true

julia> IT <: Tuple{Type{Foo{T}},Bar,T} where T
true

julia> IT <: Tuple{Type,Bar1,Any}
true

@JeffBezanson
Copy link
Member

When I try to apply a fix for this, I get the following instead:

MOSEK error 1008: License cannot be located. The default search path is ':/home/jeff/mosek/mosek.lic:'.

*** A FLEXlm error occurred. FLEXlm reported:



*** end of FLEXlm report.

which I'm not sure is really an improvement 😂 😂 😂

@chriscoey
Copy link
Author

chriscoey commented Mar 25, 2019

Ah yes, sorry, the MWE should use an open-source SDP solver so that you don't need the license.
You can try:

using CSDP, SumOfSquares, DynamicPolynomials
model = SOSModel(with_optimizer(CSDP.Optimizer))
@polyvar x
@variable(model, foo, Poly(monomials(x, 1:2)))
@constraint(model, foo >= 0)
optimize!(model)

This still causes the crash.

@JeffBezanson
Copy link
Member

No worries, just trying to make a FLEXlm joke ;)

@chriscoey
Copy link
Author

If only github had the right reaction emoji for me now

@chriscoey
Copy link
Author

IDK if useful but I bisected Julia commits for this segfault:

a811eac310ef9fde3e9fdf5ff0fab842cd4b5a84 is the first bad commit
commit a811eac310ef9fde3e9fdf5ff0fab842cd4b5a84
Author: Jeff Bezanson <jeff.bezanson@gmail.com>
Date:   Thu Jan 31 16:58:50 2019 -0500

    reduce max Union length in `tmerge` (#30833)

:040000 040000 b11366d5f172d98cbb9dab74a8051d4513348043 7e2402f6f4b2de8fe7a164e702594deb91d8aebb M	base
:040000 040000 dec5a9671bb123980c653fff83b3bf924b4b3874 3581be92e469df97ec14c81dcfe0c45970c8ff3a M	test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants