julia
julia copied to clipboard
Julia crashes with `Illegal instruction`
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)
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?
An instance of #24569 or #24316. See https://github.com/JuliaLang/julia/blob/368a8f3b9bc5a3e95eea01969182c4047290e8a5/src/codegen.cpp#L4286 :)
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?
Using https://github.com/maleadt/creduce_julia I got
for a = 1 : 10
@time begin
b && @info ""
end
end
Wow. And lol!
This was added somewhere between 1.7.0-rc1 and 1.7.0-rc2