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

Julia crashes with Illegal instruction #43668

Open
dantaras opened this issue Jan 5, 2022 · 6 comments
Open

Julia crashes with Illegal instruction #43668

dantaras opened this issue Jan 5, 2022 · 6 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@dantaras
Copy link

dantaras commented Jan 5, 2022

The code below crashes with Illegal instruction on Julia 1.6.2 and 1.7.0.

using Test

struct I end
Base.iterate(i::I) = nothing

struct A end
foo(a::A) = nothing

@testset "test" begin
    code = """
    begin
        struct B end
        foo(::Type{B}) = nothing
    end
    """
    eval(Meta.parse(code))

    for i in I()
    end 

    foo(typeof(B()))
end

Stacktrace:

Unreachable reached at 0x7f88e806230d

signal (4): Illegal instruction
...
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
...
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:871
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:825
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:929
eval at ./boot.jl:360 [inlined]
include_string at ./loading.jl:1116
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
_include at ./loading.jl:1170
include at ./Base.jl:386
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
exec_options at ./client.jl:285
_start at ./client.jl:485
jfptr__start_34281 at /home/dan/julia-1.6.2/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:560
repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:702
main at julia (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4007d8)
Allocations: 2648 (Pool: 2639; Big: 9); GC: 0
Illegal instruction (core dumped)

@maleadt
Copy link
Member

maleadt commented Jan 5, 2022

A little shorter:

foo() = whatever
begin
    eval(Meta.parse("foo(x) = nothing"))
    for _ in 0 end
    foo(nothing)
end

Interesting how eval(:(c(d) = nothing)) doesn't trigger the issue, and how the begin/end are required. Hygiene/scope issue?

@JeffBezanson
Copy link
Member

An instance of #24569 or #24316.
See

// TODO: inference is invalid if this has any effect (which it often does)
:)

@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Jan 5, 2022
@kpamnany
Copy link
Contributor

Unreachable and illegal instruction from this code as well. I also put it in a file:

function run()
   N = 800
   for k = 1:10
       @time begin
           count=0
           iter = IterateAPI.start_iterate(dict)
           while !IterateAPI.at_end(iter)
               count += 1
               IterateAPI.next!(iter)
           end
           IterateAPI.free_iterator!(iter)
           count != N && @info "ERROR"
        end
    end
end

run()

And still get:

Unreachable reached at 0x7f6ac879b4f7

[23271] signal (4): Illegal instruction
in expression starting at /home/kpamnany/ill.jl:17
run at /home/kpamnany/ill.jl:3
unknown function (ip: 0x7f6ac879b56f)
jl_apply at /home/kpamnany/julia.master/src/julia.h:1866 [inlined]
do_call at /home/kpamnany/julia.master/src/interpreter.c:126
eval_value at /home/kpamnany/julia.master/src/interpreter.c:226
eval_stmt_value at /home/kpamnany/julia.master/src/interpreter.c:177 [inlined]
eval_body at /home/kpamnany/julia.master/src/interpreter.c:624
jl_interpret_toplevel_thunk at /home/kpamnany/julia.master/src/interpreter.c:762
jl_toplevel_eval_flex at /home/kpamnany/julia.master/src/toplevel.c:912
jl_toplevel_eval_flex at /home/kpamnany/julia.master/src/toplevel.c:856
ijl_toplevel_eval_in at /home/kpamnany/julia.master/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
include_string at ./loading.jl:1525
_include at ./loading.jl:1585
include at ./Base.jl:439
jfptr_include_44956 at /home/kpamnany/julia.master/usr/lib/julia/sys.so (unknown line)
exec_options at ./client.jl:307
_start at ./client.jl:522
jfptr__start_41269 at /home/kpamnany/julia.master/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/kpamnany/julia.master/src/julia.h:1866 [inlined]
true_main at /home/kpamnany/julia.master/src/jlapi.c:567
jl_repl_entrypoint at /home/kpamnany/julia.master/src/jlapi.c:711
main at /home/kpamnany/julia.master/cli/loader_exe.c:59
unknown function (ip: 0x7f6ae1ca1d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at ./julia (unknown line)
Allocations: 548919 (Pool: 547961; Big: 958); GC: 1
Illegal instruction

Remove @time and it works as expected:

ERROR: LoadError: UndefVarError: IterateAPI not defined
Stacktrace:
 [1] run()
   @ Main ~/ill.jl:6
 [2] top-level scope
   @ ~/ill.jl:17
in expression starting at /home/kpamnany/ill.jl:17

Comment the count != N && @info "ERROR" line and it works too.

I haven't dug into it to see if this is the same underlying issue (likely), or something different?

@gbaraldi
Copy link
Member

gbaraldi commented Sep 19, 2022

Using https://github.com/maleadt/creduce_julia I got

for a = 1 : 10
 @time begin
   b && @info ""
  end
end

@kpamnany
Copy link
Contributor

Wow. And lol!

@gbaraldi
Copy link
Member

This was added somewhere between 1.7.0-rc1 and 1.7.0-rc2

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
Projects
None yet
Development

No branches or pull requests

5 participants