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 from builtin call to apply_iterate #34752

Closed
maleadt opened this issue Feb 13, 2020 · 0 comments · Fixed by #34755
Closed

Unreachable reached from builtin call to apply_iterate #34752

maleadt opened this issue Feb 13, 2020 · 0 comments · Fixed by #34755
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference regression Regression in behavior compared to a previous version

Comments

@maleadt
Copy link
Member

maleadt commented Feb 13, 2020

The following code crashes with an illegal instruction on Julia 1.1+ (bisected to #28955):

struct a{T}
  b
  c
  function a(c, d...)
    e = length(d)
    e > 1 || error()
    new{Nothing}(d, 42)
  end
end

function h(g)
  g = (d = 42, c = g.c, dontcare = 42)
  a(g...)
end

h(a(42, 42, 42))

@code_warntype:

Variables
  #self#::Core.Compiler.Const(h, false)
  g@_2::a{Nothing}
  g@_3::Union{a{Nothing}, NamedTuple{(:d, :c, :dontcare),_A} where _A<:Tuple}

Body::Union{}
1 ─      (g@_3 = g@_2)
│   %2 = (:d, :c, :dontcare)::Core.Compiler.Const((:d, :c, :dontcare), false)
│   %3 = Core.apply_type(Core.NamedTuple, %2)::Core.Compiler.Const(NamedTuple{(:d, :c, :dontcare),T} where T<:Tuple, false)
│   %4 = Base.getproperty(g@_3::a{Nothing}, :c)::Any
│   %5 = Core.tuple(42, %4, 42)::Core.Compiler.PartialStruct(Tuple{Int64,Any,Int64}, Any[Core.Compiler.Const(42, false), Any, Core.Compiler.Const(42, false)])
│        (g@_3 = (%3)(%5))
│        Core._apply_iterate(Base.iterate, Main.a, g@_3::NamedTuple{(:d, :c, :dontcare),_A} where _A<:Tuple)
└──      Core.Compiler.Const(:(return %7), false)

The trap comes from here:

julia/src/codegen.cpp

Lines 4153 to 4155 in 79f31e4

if (res.typ == jl_bottom_type || expr_t == jl_bottom_type) {
CreateTrap(ctx.builder);
}

The call codegen stumbles on is Expr(:call, Core._apply_iterate, Base.iterate, Main.a, SSAValue(4)). Probably a dup of some other unreachable reached issue, but it's hard to tell.

@maleadt maleadt added bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version labels Feb 13, 2020
@JeffBezanson JeffBezanson self-assigned this Feb 13, 2020
@JeffBezanson JeffBezanson added the compiler:inference Type inference label Feb 13, 2020
KristofferC pushed a commit that referenced this issue Feb 17, 2020
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 compiler:inference Type inference regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants