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 after Varargs change #39088

Closed
maleadt opened this issue Jan 4, 2021 · 3 comments
Closed

Unreachable after Varargs change #39088

maleadt opened this issue Jan 4, 2021 · 3 comments
Assignees
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:regression Regression in behavior compared to a previous version

Comments

@maleadt
Copy link
Member

maleadt commented Jan 4, 2021

a() = c((1,), (1,1,1,1))
c(d::NTuple{T}, ::NTuple{T}) where T = d
c(d::NTuple{f}, b) where f = c((d..., f), b)
j(h::NTuple{T}, ::NTuple{T} = a()) where T = nothing
j((1,1,1,1))
Unreachable reached at 0x7f5e68033107

signal (4): Illegal instruction
in expression starting at /home/tim/Julia/tools/creduce/main.jl:5
j at /home/tim/Julia/tools/creduce/main.jl:4
unknown function (ip: 0x7f5e68033160)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2232 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2414
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1708 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:117
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:206
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:157 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:563
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:670
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:879
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:827
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:931
eval at ./boot.jl:369 [inlined]
...

Bisected to #38136.

@maleadt maleadt added the kind:regression Regression in behavior compared to a previous version label Jan 4, 2021
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 4, 2021

You only need c to start to see corruption:

julia> c((), (1,1,1,1))
(0, 1, 2, 3, 1)

julia> c((1,), (1,1,1,1))
(1, 1, 2, 3, 64)

julia> @code_typed c((1,), (1,1,1,1))
CodeInfo(
    @ REPL[2]:1 within `c'
1 ─ %1 = Core.getfield(d, 1)::Int64
│   @ REPL[2]:1 within `c' @ REPL[2]:1 @ REPL[2]:1
│   %2 = Core.tuple(%1, 1, 2, 3)::NTuple{4, Int64}
│   @ REPL[2]:1 within `c'
└──      return %2
) => NTuple{4, Int64}

@Keno
Copy link
Member

Keno commented Jan 4, 2021

Reduced:

julia> typeintersect(Tuple{NTuple{N, Int}, NTuple{N, Int}} where N, Tuple{Tuple{Int, Vararg{Any}}, NTuple{4, Int64}})
Tuple{NTuple{5, Int64}, NTuple{4, Int64}}

@Keno Keno added the domain:types and dispatch Types, subtyping and method dispatch label Jan 4, 2021
@JeffBezanson JeffBezanson added this to the 1.7 milestone Jan 5, 2021
@vtjnash vtjnash removed this from the 1.7 milestone Jun 3, 2021
martinholters added a commit that referenced this issue Oct 19, 2021
…and `__dec`

The underlying intersection bug (ref. #39088) looks like
```
julia> typeintersect(Tuple{Tuple{Any, Vararg{Any, N}}, Tuple{Any, Vararg{Any, N}}} where N, Tuple{Tuple{Int,Int,Int}, Tuple})
Tuple{Tuple{Int64, Int64, Int64}, NTuple{4, Any}}
```

It leads to the argument types of the functions with signatures of this
type to be inferred wrongly, not actually matching the signature, which
easily leads to problems down the road.

For the four methods touched here, the fact that the two tuple arguments
must have the same length is not actually relevant for dispatch as they
are internal functions which are only called if this actually holds.
Also, this change will just replace the method error with another error
if, for some reason, these fuctions would get called for tuples of
unequal length.
martinholters added a commit that referenced this issue Oct 19, 2021
...by removing unnecessary type checks/assertions. This basically
restores the function bodies to what they looked like prior to #40594
and only keeps the changed signatures (with the additional changes to
circumvent #39088..
KristofferC pushed a commit that referenced this issue Oct 19, 2021
...by removing unnecessary type checks/assertions. This basically
restores the function bodies to what they looked like prior to #40594
and only keeps the changed signatures (with the additional changes to
circumvent #39088.
KristofferC pushed a commit that referenced this issue Oct 19, 2021
...by removing unnecessary type checks/assertions. This basically
restores the function bodies to what they looked like prior to #40594
and only keeps the changed signatures (with the additional changes to
circumvent #39088.

(cherry picked from commit df81a0d)
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Feb 22, 2022
...by removing unnecessary type checks/assertions. This basically
restores the function bodies to what they looked like prior to JuliaLang#40594
and only keeps the changed signatures (with the additional changes to
circumvent JuliaLang#39088.
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Mar 8, 2022
...by removing unnecessary type checks/assertions. This basically
restores the function bodies to what they looked like prior to JuliaLang#40594
and only keeps the changed signatures (with the additional changes to
circumvent JuliaLang#39088.
N5N3 added a commit to N5N3/julia that referenced this issue Aug 31, 2022
N5N3 added a commit to N5N3/julia that referenced this issue Sep 1, 2022
@N5N3
Copy link
Member

N5N3 commented Sep 2, 2022

close by #46446

@N5N3 N5N3 closed this as completed Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants