Description
This problem happens on Julia 1.6.7, 1.7.3, 1.8.5, 1.9.3, 1.10-beta2 and master. It might possibly also happens on older versions, but Automa.jl only supports Julia 1.6 and above.
MWE:
Reduced to this snippet with the help of @maleadt
struct Tokenizer end
define_iterate() = :(Base.iterate(::Tokenizer) = nothing)
for x in 1
eval(define_iterate())
iterate(Tokenizer())
end
Old way of of reproducing
Make a test file /tmp/foo.jl
with the following content
using Automa
for goto in (false,)
make_tokenizer([re"ADF"]; goto=false) |> eval
collect(Tokenizer{UInt32, String, 1}("")) == []
end
Now, in a project with Automa master branch, #733b8cf (or the released v1.0.0)
julia> using Automa
julia> include("/tmp/foo.jl") # crashes
Interestingly, if, instead of generating the code during the session, we instead manually write out the code like this, it does not crash:
julia> open("/tmp/foo3.jl", "w") do io
println(io, "using Automa")
println(io, "for goto in (false,)")
println(io, make_tokenizer([re"ADF"]; goto=false))
println(io, "collect(Tokenizer{UInt32, String, 1}(\"\")) == []")
println(io, "end")
end
Also, including the file after manually running make_tokenizer
doesn't crash either:
julia> using Automa
julia> make_tokenizer([re"ADF"]; goto=false) |> eval
julia> include("/tmp/foo.jl")
...which suggests to me that the bug could have something to do with the Julia interpreter, which runs the top-level for loop in foo.jl
Crash message:
Unreachable reached at 0x7f4628f24b7a
[54249] signal (4.2): Illegal instruction
in expression starting at /tmp/foo.jl:3
_collect at ./array.jl:768
collect at ./array.jl:757
top-level scope at /tmp/foo.jl:7
jl_toplevel_eval_flex at /home/jakni/code/julia/src/toplevel.c:925
jl_toplevel_eval_flex at /home/jakni/code/julia/src/toplevel.c:877
ijl_toplevel_eval_in at /home/jakni/code/julia/src/toplevel.c:985
eval at ./boot.jl:396 [inlined]
include_string at ./loading.jl:2070
_include at ./loading.jl:2130
include at ./client.jl:489
unknown function (ip: 0x7f4628f248e5)
jl_apply at /home/jakni/code/julia/src/julia.h:1993 [inlined]
do_call at /home/jakni/code/julia/src/interpreter.c:125
eval_value at /home/jakni/code/julia/src/interpreter.c:222
eval_stmt_value at /home/jakni/code/julia/src/interpreter.c:173 [inlined]
eval_body at /home/jakni/code/julia/src/interpreter.c:634
jl_interpret_toplevel_thunk at /home/jakni/code/julia/src/interpreter.c:774
jl_toplevel_eval_flex at /home/jakni/code/julia/src/toplevel.c:934
jl_toplevel_eval_flex at /home/jakni/code/julia/src/toplevel.c:877
ijl_toplevel_eval_in at /home/jakni/code/julia/src/toplevel.c:985
eval at ./boot.jl:396 [inlined]
eval_user_input at /home/jakni/code/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:150
repl_backend_loop at /home/jakni/code/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:246
#start_repl_backend#46 at /home/jakni/code/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:231
start_repl_backend at /home/jakni/code/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:228
#run_repl#59 at /home/jakni/code/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:387
run_repl at /home/jakni/code/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:373
jfptr_run_repl_92277 at /home/jakni/code/julia/usr/lib/julia/sys.so (unknown line)
#1043 at ./client.jl:432
jfptr_YY.1043_83306 at /home/jakni/code/julia/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/jakni/code/julia/src/julia.h:1993 [inlined]
jl_f__call_latest at /home/jakni/code/julia/src/builtins.c:812
#invokelatest#2 at ./essentials.jl:899 [inlined]
invokelatest at ./essentials.jl:896 [inlined]
run_main_repl at ./client.jl:415
exec_options at ./client.jl:332
_start at ./client.jl:552
jfptr__start_83334 at /home/jakni/code/julia/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/jakni/code/julia/src/julia.h:1993 [inlined]
true_main at /home/jakni/code/julia/src/jlapi.c:582
jl_repl_entrypoint at /home/jakni/code/julia/src/jlapi.c:731
main at /home/jakni/code/julia/cli/loader_exe.c:58
unknown function (ip: 0x7f462a227ccf)
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/jakni/code/julia/julia (unknown line)
Allocations: 4208949 (Pool: 4205166; Big: 3783); GC: 6
zsh: illegal hardware instruction (core dumped) ~/code/julia/julia --project=. --startup-file=no