Skip to content

julia crashes during method disptch #36869

@OkonSamuel

Description

@OkonSamuel

recently julia dispatch used a less specific method rather than the expected more specific method. While playing around i discovered that following code crashes julia.

julia> using SentinelArrays
b 
julia> b =SentinelArray([1,2,3,4])
4-element SentinelArray{Int64,1,Int64,Missing,Array{Int64,1}}:
 1
 2
 3
 4

julia> f(::Type{T}, y, x::AbstractVector{T}) where T = (T, y)
f (generic function with 1 method)

julia> function g(x, y)
       if x == Int64
        z = true
       else
        z= false
        end
        return f(x, z, y)
        end
g (generic function with 1 method)

julia> f(Union{Missing, Int64}, true, b)
(Union{Missing, Int64}, true)

julia> Union{Missing, Int64} == Int64
false

julia> f(Union{Missing, Int64}, true, b)
(Union{Missing, Int64}, true)

julia> f(Union{Missing, Int64}, false, b)
(Union{Missing, Int64}, false)

julia> g(Union{Missing, Int64}, b)
Unreachable reached at 0x7ff87d4a2085signal (4): Illegal instruction
in expression starting at REPL[9]:1
g at ./REPL[4]:7
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2159 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1700 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:369
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:458
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:409 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:817
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:911
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:819
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:769
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:848
eval at ./boot.jl:331
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2145 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:358
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2145 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1700 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:687
unknown function (ip: (nil))
Allocations: 30348217 (Pool: 30340443; Big: 7774); GC: 28
Illegal instruction (core dumped)

is this behavior expected??

julia> versioninfo()
Julia Version 1.4.2
Commit 44fa15b150* (2020-05-23 18:35 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, broadwell)

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviortypes and dispatchTypes, subtyping and method dispatch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions