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

Internal error in runtime when testing Polyhedra.jl #44238

Closed
KristofferC opened this issue Feb 18, 2022 · 4 comments · Fixed by #44416
Closed

Internal error in runtime when testing Polyhedra.jl #44238

KristofferC opened this issue Feb 18, 2022 · 4 comments · Fixed by #44416
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) regression Regression in behavior compared to a previous version
Milestone

Comments

@KristofferC
Copy link
Member

https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/f51f24c_vs_2ca8b0c/Polyhedra.primary.log

Internal error: encountered unexpected error in runtime:
MethodError(f=Base.string, args=(Expr(:call, :==, Expr(:call, :length, :aparams), Expr(:call, :length, :mparams)),), world=0x000000000000124a)
jl_method_error_bare at /workspace/srcdir/src/gf.c:1851
jl_method_error at /workspace/srcdir/src/gf.c:1869
jl_lookup_generic_ at /workspace/srcdir/src/gf.c:2494 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2509
macro expansion at ./error.jl:231 [inlined]
ir_inline_unionsplit! at ./compiler/ssair/inlining.jl:483
batch_inline! at ./compiler/ssair/inlining.jl:617
ssa_inlining_pass! at ./compiler/ssair/inlining.jl:85
jfptr_ssa_inlining_passNOT._15640.clone_1 at /opt/julia/lib/julia/sys.so (unknown line)
_jl_invoke at /workspace/srcdir/src/gf.c:2331 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2513
run_passes at ./compiler/optimize.jl:514
optimize at ./compiler/optimize.jl:505 [inlined]
_typeinf at ./compiler/typeinfer.jl:253
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:856
abstract_call_method at ./compiler/abstractinterpretation.jl:593
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:132
abstract_call_known at ./compiler/abstractinterpretation.jl:1593
...

Seems to error here:

@assert length(aparams) == length(mparams)

@KristofferC KristofferC added this to the 1.8 milestone Feb 18, 2022
@KristofferC
Copy link
Member Author

@vtjnash
Copy link
Member

vtjnash commented Feb 18, 2022

Added by ce70402, though I don't know why it would be making an assumption like that.

@JeffBezanson JeffBezanson added compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) regression Regression in behavior compared to a previous version labels Feb 18, 2022
@ianatol
Copy link
Member

ianatol commented Feb 23, 2022

MWE for the Polyhedra one:

using Polyhedra
v = convexhull([1, 0, 0]) + conichull(Ray([0, 1, 0]), Line([0, 0, 1]))

vtjnash added a commit that referenced this issue Mar 2, 2022
Intersection cannot deal with this `metharg`, so it does not simplify
the type at all when handling this case. This can cause us to run into
an assertion later, where we assume the intersection of a non-Varags
type will always return a simple DataType without Varargs.

Fixes #44238

    atype = Tuple{typeof(Base.similar),
      Tuple{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T},
      Array{_A, 1} where _A,
      Array{_C, 1} where _C,
      Array{_B, 1} where _B}

    metharg = Tuple{typeof(Base.similar),
      Tuple{Vararg{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T}},
      Vararg{Union{Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HyperPlane{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HalfSpace{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:AbstractArray{T, 1}, Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Line{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Ray{T, AT} where AT<:AbstractArray{T, 1})} where T}}

Currently `typeintersection(atype, metharg) === metharg`
@vtjnash
Copy link
Member

vtjnash commented Mar 2, 2022

It looks like these packages defines some unnecessarily complicated Union types, which probably hurts there performance quite a lot (e.g. Polyhedra.It). But we should be able to keep it from printing an internal error.

aviatesk pushed a commit that referenced this issue Mar 4, 2022
…4416)

Intersection cannot deal with this `metharg`, so it does not simplify
the type at all when handling this case. This can cause us to run into
an assertion later, where we assume the intersection of a non-Varags
type will always return a simple DataType without Varargs.

Fixes #44238

    atype = Tuple{typeof(Base.similar),
      Tuple{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T},
      Array{_A, 1} where _A,
      Array{_C, 1} where _C,
      Array{_B, 1} where _B}

    metharg = Tuple{typeof(Base.similar),
      Tuple{Vararg{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T}},
      Vararg{Union{Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HyperPlane{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HalfSpace{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:AbstractArray{T, 1}, Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Line{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Ray{T, AT} where AT<:AbstractArray{T, 1})} where T}}

Currently `typeintersection(atype, metharg) === metharg`
KristofferC pushed a commit that referenced this issue Mar 4, 2022
…4416)

Intersection cannot deal with this `metharg`, so it does not simplify
the type at all when handling this case. This can cause us to run into
an assertion later, where we assume the intersection of a non-Varags
type will always return a simple DataType without Varargs.

Fixes #44238

    atype = Tuple{typeof(Base.similar),
      Tuple{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T},
      Array{_A, 1} where _A,
      Array{_C, 1} where _C,
      Array{_B, 1} where _B}

    metharg = Tuple{typeof(Base.similar),
      Tuple{Vararg{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T}},
      Vararg{Union{Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HyperPlane{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HalfSpace{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:AbstractArray{T, 1}, Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Line{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Ray{T, AT} where AT<:AbstractArray{T, 1})} where T}}

Currently `typeintersection(atype, metharg) === metharg`

(cherry picked from commit ffc5ffa)
KristofferC pushed a commit that referenced this issue Mar 7, 2022
…4416)

Intersection cannot deal with this `metharg`, so it does not simplify
the type at all when handling this case. This can cause us to run into
an assertion later, where we assume the intersection of a non-Varags
type will always return a simple DataType without Varargs.

Fixes #44238

    atype = Tuple{typeof(Base.similar),
      Tuple{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T},
      Array{_A, 1} where _A,
      Array{_C, 1} where _C,
      Array{_B, 1} where _B}

    metharg = Tuple{typeof(Base.similar),
      Tuple{Vararg{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T}},
      Vararg{Union{Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HyperPlane{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HalfSpace{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:AbstractArray{T, 1}, Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Line{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Ray{T, AT} where AT<:AbstractArray{T, 1})} where T}}

Currently `typeintersection(atype, metharg) === metharg`

(cherry picked from commit ffc5ffa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants