Skip to content

Unreachable reached by deleting an extended method (v1.11.5) #58986

@DanielMSussman

Description

@DanielMSussman

I am able to trigger an "Unreachable reached at 0x7c4859693328" error with the following:

"Using Revise" approach

This is my original MWE.

  1. Create this file (test.jl):
import Base: *, ^ 

struct D<: Number
    val::Float64
    deriv::Float64
end

*(x::D,y::D) = D(x.val*y.val,
                          x.val*y.deriv+x.deriv*y.val)

^(x::D,y::D) = D(x.val^y.val,
                        x.val^(y.val-1)*
                        (y.val*x.deriv + x.val*y.deriv*log(x.val))
                        )
^(x::D,n::Real) = D(x.val^n,n*x.val^(n-1)*x.deriv)

function test()
    D(1.0,1.0)^2
end
  1. Start a new Julia session, use Revise to includet this file, and run the test function (the startup-file=no is not necessary to trigger the bug)
$ julia --startup-file=no
julia> using Revise
julia> includet("test.jl")
julia> test()

ERROR: MethodError: ^(::D, ::Int64) is ambiguous.

Candidates:
  ^(x::D, n::Real)
    @ Main ~/test/bug/test.jl:15
  ^(x::Number, p::Integer)
    @ Base intfuncs.jl:349

Possible fix, define
  ^(::D, ::Integer)

Stacktrace:
 [1] literal_pow
   @ ./intfuncs.jl:389 [inlined]
 [2] test()
   @ Main ~/test/bug/test.jl:18
 [3] top-level scope
   @ REPL[2]:1
  1. Switch back to the test.jl file and comment out the second of the two exponentiation methods (the ^(x::D,n::Real) = D(x.val^n,n*x.val^(n-1)*x.deriv) one, that is), and save the file.

  2. Back in the REPL:

julia> test()
Unreachable reached at 0x7c4859693328

[3277] signal 4 (2): Illegal instruction
in expression starting at REPL[2]:1
literal_pow at ./intfuncs.jl:389 [inlined]
test at /home/daniel/test/bug/test.jl:18
unknown function (ip: 0x7c485969334f)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
do_call at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:126
eval_value at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:223
eval_stmt_value at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:174 [inlined]
eval_body at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:666
jl_interpret_toplevel_thunk at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:824
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:943
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:886
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:886
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:886
ijl_toplevel_eval_in at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:994
eval at ./boot.jl:430 [inlined]
eval_user_input at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:261
repl_backend_loop at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:368
#start_repl_backend#59 at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:343
start_repl_backend at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:340
#run_repl#76 at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:500
run_repl at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:486
jfptr_run_repl_10123.1 at /home/daniel/.julia/juliaup/julia-1.11.5+0.x64.linux.gnu/share/julia/compiled/v1.11/REPL/u0gqU_4x0TT.so (unknown line)
#1150 at ./client.jl:446
jfptr_YY.1150_14797.1 at /home/daniel/.julia/juliaup/julia-1.11.5+0.x64.linux.gnu/share/julia/compiled/v1.11/REPL/u0gqU_4x0TT.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_f__call_latest at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/builtins.c:875
#invokelatest#2 at ./essentials.jl:1055 [inlined]
invokelatest at ./essentials.jl:1052 [inlined]
run_main_repl at ./client.jl:430
repl_main at ./client.jl:567 [inlined]
_start at ./client.jl:541
jfptr__start_73430.1 at /home/daniel/.julia/juliaup/julia-1.11.5+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
true_main at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/jlapi.c:900
jl_repl_entrypoint at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/jlapi.c:1059
main at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/cli/loader_exe.c:58
unknown function (ip: 0x7c4865e2a1c9)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)
Allocations: 1309182 (Pool: 1309102; Big: 80); GC: 2
Illegal instruction (core dumped)

version info

julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 22 × Intel(R) Core(TM) Ultra 7 155H
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 22 virtual cores)

I have also reproduced this on a different Windows 11 machine (also v1.11.5)

Other similar (simpler) failure modes

When I first had this come up I posted a discourse thread here. I don't want to take credit for other people's (much better) sleuthing: user /u/benny pointed out that Revise.jl is not needed at all, and that the same bug reproduces in v1.11.6, v1.10.10, v1.9.4, Windows 11.

/u/benny also proposed an even simpler MWE here, which I copy to this issue since it seems to get to the heart of things directly:

julia> begin
       abstract type AbstractBlah end
       struct Blah<:AbstractBlah end
       foo(::Blah, ::AbstractBlah) = 1
       foo(::AbstractBlah, ::Blah) = -1
       test() = foo(Blah(), Blah())
       end
test (generic function with 1 method)

julia> foo(Blah(), Blah())
ERROR: MethodError: foo(::Blah, ::Blah) is ambiguous.

Candidates:
  foo(::AbstractBlah, ::Blah)
    @ Main REPL[1]:5
  foo(::Blah, ::AbstractBlah)
    @ Main REPL[1]:4

Possible fix, define
  foo(::Blah, ::Blah)

Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

julia> test() # same outcome as expected from forwarding to same call
ERROR: MethodError: foo(::Blah, ::Blah) is ambiguous.

Candidates:
  foo(::AbstractBlah, ::Blah)
    @ Main REPL[1]:5
  foo(::Blah, ::AbstractBlah)
    @ Main REPL[1]:4

Possible fix, define
  foo(::Blah, ::Blah)

Stacktrace:
 [1] test()
   @ Main .\REPL[1]:6
 [2] top-level scope
   @ REPL[3]:1

julia> Base.delete_method(methods(foo)[2]) # no Base methods to avoid deleting

julia> foo(Blah(), Blah()) # properly invalidated previous MethodError call
-1

julia> test()

Unreachable reached at 00000204af55136f

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ILLEGAL_INSTRUCTION at 0x204af55136f -- test at .\REPL[1]:6
in expression starting at REPL[6]:1
test at .\REPL[1]:6
unknown function (ip: 00000204af5513a4)
jl_apply at C:/workdir/src\julia.h:2157 [inlined]
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    types 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