Skip to content

Hard Crash: "Unreachable reached" when using the Subtyping Operator to compare against Union{<: T}  #48374

@Clemapfel

Description

@Clemapfel

@fjebaker discovered that this line hard-crashes Julia, tested on 1.7 and 1.8 on both Mac and Linux, though on Mac it does not signal(4) but hang indefinitely instead.

test(x::T) where T = T <: Union{<: Nothing}; test(12)
Unreachable reached at 0x7fbce15a9235

signal (4): Illegal instruction
in expression starting at REPL[2]:1
test at ./REPL[2]:1
unknown function (ip: 0x7fbce15a9259)
unknown function (ip: 0x7fbd46c6768b)
unknown function (ip: 0x7fbd46c66f56)
unknown function (ip: 0x7fbd46c67d92)
unknown function (ip: 0x7fbd46c68bdc)
unknown function (ip: 0x7fbd46c86919)
unknown function (ip: 0x7fbd46c87416)
unknown function (ip: 0x7fbd46c87416)
ijl_toplevel_eval_in at /usr/bin/../lib64/julia/libjulia-internal.so.1 (unknown line)
unknown function (ip: 0x7fbd250f9417)
unknown function (ip: 0x7fbd250f9b72)
unknown function (ip: 0x7fbd2488897d)
unknown function (ip: 0x7fbd2492d352)
unknown function (ip: 0x7fbd2492d773)
unknown function (ip: 0x7fbd2492d78f)
unknown function (ip: 0x7fbd24a8f20e)
unknown function (ip: 0x7fbd24a8f2ab)
jl_f__call_latest at /usr/bin/../lib64/julia/libjulia-internal.so.1 (unknown line)
unknown function (ip: 0x7fbd2550bb5e)
unknown function (ip: 0x7fbd25518cb5)
unknown function (ip: 0x7fbd250038d7)
unknown function (ip: 0x7fbd25003a08)
unknown function (ip: 0x7fbd46cb0926)
jl_repl_entrypoint at /usr/bin/../lib64/julia/libjulia-internal.so.1 (unknown line)
main at julia (unknown line)
__libc_start_call_main at /usr/bin/../lib64/libc.so.6 (unknown line)
__libc_start_main at /usr/bin/../lib64/libc.so.6 (unknown line)
_start at julia (unknown line)
Allocations: 2903 (Pool: 2891; Big: 12); GC: 0
Illegal instruction (core dumped)

It is unrelated to Nothing and the type of x, any other type in either place causes the crash.

More puzzling, the following works:

julia> x = 12; typeof(x) <: Union{<: Nothing}  # works
false

julia> test(x) = typeof(x) <: Union{<: Nothing}; test(12) # crash
Unreachable reached at 0x7fad662de155

Can someone explain this behavior? The fact it cause a proper crash C-side makes me suspicious that this may be a bug in the C API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions