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

Internal BoundsError in the compiler #37154

Closed
benhamad opened this issue Aug 22, 2020 · 11 comments
Closed

Internal BoundsError in the compiler #37154

benhamad opened this issue Aug 22, 2020 · 11 comments
Labels
bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) priority This should be addressed urgently

Comments

@benhamad
Copy link

benhamad commented Aug 22, 2020

The following code causes an internal error in Julia 1.4.2 ( and 1.5.0, see my other comment below)

update_lock = Threads.ReentrantLock()
function update()
    while(true)
        try
            for i in 1:1
                lock(update_lock)
                counter += 1
                unlock(update_lock)
            end
        catch e
            nothing
        end
    end
end

You will need to manually kill the server due to the infinite loop 😅. The logic behind the code is to keep trying something that can result in an exception, if it does, do some handling and then go back trying that thing again, until a global state has changed and then we exist.

Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Core.Compiler.BasicBlock, (5,)}[
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=1, stop=2), preds=Array{Int64, (1,)}[5], succs=Array{Int64, (1,)}[2]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=3, stop=5), preds=Array{Int64, (1,)}[1], succs=Array{Int64, (2,)}[4, 3]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=6, stop=11), preds=Array{Int64, (1,)}[2], succs=Array{Int64, (0,)}[]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=12, stop=14), preds=Array{Int64, (1,)}[2], succs=Array{Int64, (1,)}[5]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=15, stop=16), preds=Array{Int64, (1,)}[4], succs=Array{Int64, (1,)}[1])], i=(0,))
jl_bounds_error_ints at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
getindex at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
jfptr_getindex_1956 at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
jl_apply_generic at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
replace_code_newstyle! at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
optimize at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
typeinf at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
typeinf_ext at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
typeinf_ext at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
jfptr_typeinf_ext_1 at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
jl_apply_generic at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
jl_type_infer at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
jl_compile_method_internal at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
jl_apply_generic at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
do_call at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
eval_value at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
eval_body at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
jl_interpret_toplevel_thunk at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
top-level scope at REPL[2]:1
jl_toplevel_eval_flex at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
jl_toplevel_eval_flex at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
jl_toplevel_eval_in at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
eval at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
jl_apply_generic at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
eval_user_input at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
#26 at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/lib/julia/sys.so (unknown line)
jl_apply_generic at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
start_task at /nix/store/kbcgz4zm5vs3sprmj45jc2lhrffmld22-julia-1.4.2-patched/bin/../lib/libjulia.so.1 (unknown line)
unknown function (ip: (nil))

This error seems to be related to #30093

@KristofferC
Copy link
Member

For issues like this, please try on the latest released version (1.5).

@benhamad
Copy link
Author

I confirm that this is still the case for Julia 1.5

Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Core.Compiler.BasicBlock, (5,)}[Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=1, stop=2), preds=Array{Int64, (1,)}[5], succs=Array{Int64, (1,)}[2]), Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=3, stop=5), preds=Array{Int64, (1,)}[1], succs=Array{Int64, (2,)}[4, 3]), Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=6, stop=11), preds=Array{Int64, (1,)}[2], succs=Array{Int64, (0,)}[]), Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=12, stop=14), preds=Array{Int64, (1,)}[2], succs=Array{Int64, (1,)}[5]), Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(start=15, stop=16), preds=Array{Int64, (1,)}[4], succs=Array{Int64, (1,)}[1])], i=(0,))
jl_bounds_error_ints at /buildworker/worker/package_linux64/build/src/rtutils.c:183
getindex at ./array.jl:809
jfptr_getindex_23618.clone_1 at /tmp/julia-1.5.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2214 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2398
replace_code_newstyle! at ./compiler/ssair/legacy.jl:83
optimize at ./compiler/optimize.jl:220
typeinf at ./compiler/typeinfer.jl:33
typeinf_ext at ./compiler/typeinfer.jl:570
typeinf_ext at ./compiler/typeinfer.jl:601
jfptr_typeinf_ext_20209.clone_1 at /tmp/julia-1.5.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2214 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2398
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1690 [inlined]
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:296
jl_generate_fptr at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:290
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1964
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1919 [inlined]
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2224 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2398
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1690 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:117
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:206
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:157 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:566
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:660
top-level scope at REPL[2]:1
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:840
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:790
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:883
eval at ./boot.jl:331
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2214 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2398
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:134
repl_backend_loop at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:195
start_repl_backend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:180
#run_repl#37 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:292
run_repl at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2231 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2398
#806 at ./client.jl:399
jfptr_YY.806_52378.clone_1 at /tmp/julia-1.5.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2214 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2398
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1690 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:655
jl_f__apply_latest at /buildworker/worker/package_linux64/build/src/builtins.c:705
#invokelatest#1 at ./essentials.jl:710 [inlined]
invokelatest at ./essentials.jl:709 [inlined]
run_main_repl at ./client.jl:383
exec_options at ./client.jl:313
_start at ./client.jl:506
jfptr__start_43701.clone_1 at /tmp/julia-1.5.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2214 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2398
jl_apply at /buildworker/worker/package_linux64/build/ui/../src/julia.h:1690 [inlined]
true_main at /buildworker/worker/package_linux64/build/ui/repl.c:106
main at /buildworker/worker/package_linux64/build/ui/repl.c:227
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /tmp/julia-1.5.0/bin/julia (unknown line)

@KristofferC
Copy link
Member

Thanks.

@maleadt
Copy link
Member

maleadt commented Aug 24, 2020

Reduced to:

while
  try
    a += 0
  catch end
end

This doesn't only reproduce the bounds error, but also segfaults the GC 🎉

@iamed2
Copy link
Contributor

iamed2 commented Aug 24, 2020

I think this is related; this happens on nightly:

Julia Version 1.6.0-DEV.706
Commit 92248d213e (2020-08-24 02:31 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake-avx512)
Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{UInt64, (31,)}[0x0000000000000001, 0x0000000000000002, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000003, 0x0000000000000004, 0x0000000000000005, 0x0000000000000000, 0x0000000000000006, 0x0000000000000007, 0x0000000000000000, 0x0000000000000008, 0x0000000000000009, 0x0000000000000000], i=(32,))
jl_bounds_error_ints at /buildworker/worker/package_linux64/build/src/rtutils.c:183
getindex at ./array.jl:809 [inlined]
getindex at ./abstractarray.jl:1122 [inlined]
DFS at ./compiler/ssair/domtree.jl:197
SNCA at ./compiler/ssair/domtree.jl:269
construct_domtree at ./compiler/ssair/domtree.jl:121
getfield_elim_pass! at ./compiler/ssair/passes.jl:729
run_passes at ./compiler/ssair/driver.jl:131
optimize at ./compiler/optimize.jl:172
typeinf at ./compiler/typeinfer.jl:35
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1388
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1388
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1373
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1388
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1388
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1388
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1388
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1373
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:536
abstract_call_method at ./compiler/abstractinterpretation.jl:465
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:129
abstract_call_known at ./compiler/abstractinterpretation.jl:1003
abstract_call at ./compiler/abstractinterpretation.jl:1026
abstract_call at ./compiler/abstractinterpretation.jl:1010
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1132
typeinf_local at ./compiler/abstractinterpretation.jl:1388
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1444
typeinf at ./compiler/typeinfer.jl:12
typeinf_ext at ./compiler/typeinfer.jl:623
typeinf_ext_toplevel at ./compiler/typeinfer.jl:656
typeinf_ext_toplevel at ./compiler/typeinfer.jl:652
jfptr_typeinf_ext_toplevel_9597 at /usr/local/julia/lib/julia/sys.so (unknown line)
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1753 [inlined]
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:300
jl_generate_fptr at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:301
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1888
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1839 [inlined]
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2143 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2334
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1753 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:117
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:206
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:436
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:491
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:491
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:491
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:491
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:659
macro expansion at /builds/invenia/GPForecasters.jl/test/miso_run.jl:211 [inlined]
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1114 [inlined]
macro expansion at /builds/invenia/GPForecasters.jl/test/miso_run.jl:191 [inlined]
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1114 [inlined]
top-level scope at /builds/invenia/GPForecasters.jl/test/miso_run.jl:23
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:838
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:788
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:881
eval at ./boot.jl:344 [inlined]
include_string at ./loading.jl:1104
_include at ./loading.jl:1158
include at ./client.jl:443
macro expansion at /builds/invenia/GPForecasters.jl/test/runtests.jl:27 [inlined]
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1189 [inlined]
macro expansion at /builds/invenia/GPForecasters.jl/test/runtests.jl:26 [inlined]
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1114 [inlined]
top-level scope at /builds/invenia/GPForecasters.jl/test/runtests.jl:16
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:832
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:788
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:881
eval at ./boot.jl:344 [inlined]
include_string at ./loading.jl:1104
_include at ./loading.jl:1158
include at ./client.jl:443
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1753 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:117
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:206
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:157 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:551
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:659
top-level scope at none:6
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:838
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:788
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:881
eval at ./boot.jl:344
exec_options at ./client.jl:260
_start at ./client.jl:484
jfptr__start_22849 at /usr/local/julia/lib/julia/sys.so (unknown line)
jl_apply at /buildworker/worker/package_linux64/build/ui/../src/julia.h:1753 [inlined]
true_main at /buildworker/worker/package_linux64/build/ui/repl.c:106
main at /buildworker/worker/package_linux64/build/ui/repl.c:227
__libc_start_main at /lib64/libc.so.6 (unknown line)
_start at /usr/local/julia/bin/julia (unknown line)

@vchuravy
Copy link
Member

vchuravy commented Aug 24, 2020

@iamed2 do you have a reproducer for that? It might be related to #37147

(also I suspect that it a different bug from the original report)

@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) labels Aug 24, 2020
@ianatol
Copy link
Member

ianatol commented Sep 24, 2021

This bug seems to stem from certain functions (like the examples given in this thread) generating PhiNodes in the entry block.

Since PhiNodes imply that the block they are in has predecessors, IR with PhiNodes in its entry block is malformed.

More specifically, on the Julia side, these entry block PhiNodes give a bounds error in replace_code_newstyle! by having an edge that refers to some non-existent predecessor.

@vtjnash and I went over some possible solutions for when we detect this (seemingly rare) bug:

  1. Inserting a goto %2 as the first instruction in the entry block

    • The examples that produce this bug tend to have some exception being thrown in the 2nd block, so going there first would hopefully result in the error we want actually happening.
  2. Inserting a new entry block before our current one

    • This would technically make the program no longer malformed, as the PhiNodes now refer to a real predecessor. Results may vary in terms of how LLVM will react.

In both cases, some handling of the PhiNode edges may be required to avoid the bounds error in replace_code_newstyle!. Another possibility would be to throw the whole thing out and give a different kind of error once we detect a PhiNode in the entry block.

Further input on this fix is greatly appreciated!

@vtjnash
Copy link
Member

vtjnash commented Sep 25, 2021

Options 1 and 2 seem to be the same? (Though may require some special work to ensure the goto node that splits that block is treated as valid and not removed later)

@PallHaraldsson
Copy link
Contributor

The MWE at #37154#issuecomment-678933001 still crashes rc3 (and "a4f7f2d1e4 (1 day old master)"), but the original crashes neither.

I'm not sure this is too helpful, but should there be a random amount (on master) of allocations; and much more than on rc3?

Possibly I was just lucky with rc3, getting (seemingly) always the same error, but on master, while often getting similar (length of error), sometimes I get way longer text, with something extra.

Always on rc3: "Allocations: 2720 (Pool: 2710; Big: 10); GC: 0", while on master the last two lines have slightly different numbers:

Allocations: 114539 (Pool: 112341; Big: 2198); GC: 0
Aborted (core dumped)

I was surprised to see e.g. SuiteSparse in the output for master:

[..]
GC error (probable corruption) :
Allocations: 114539 (Pool: 112341; Big: 2198); GC: 0

!!! ERROR in jl_ -- ABORTING !!!
[..]
0x7fe7b0e450c0: Queued root: 0x7fe84e283780 :: 0x7fe849a0d990 (bits: 3)
        of type Base.IdDict{Any, Any}
0x7fe7b0e450d8: Queued root: 0x7fe8498b66e0 :: 0x7fe84988bbf0 (bits: 3)
        of type Core.SimpleVector
0x7fe7b0e450f0: Queued root: 0x7fe84d212370 :: 0x7fe84ae5f900 (bits: 3)
        of type Array{Base.Multimedia.AbstractDisplay, 1}
0x7fe7b0e45108: Queued root: 0x7fe84b287b90 :: 0x7fe849ae3770 (bits: 3)
        of type Array{String, 1}
0x7fe7b0e45120: Queued root: 0x7fe84d2b22b0 :: 0x7fe84add2fd0 (bits: 3)
        of type Random.FileRef
0x7fe7b0e45138: Queued root: 0x7fe84d91d070 :: 0x7fe849b0c780 (bits: 3)
        of type Base.InvasiveLinkedList{Task}
0x7fe7b0e45150: Queued root: 0x7fe84c90ffd0 :: 0x7fe84ba84b40 (bits: 3)
        of type Array{Ref{SuiteSparse.LibSuiteSparse.cholmod_common_struct}, 1}
0x7fe7b0e45168: Queued root: 0x7fe84c53c8f0 :: 0x7fe84988bd00 (bits: 3)
[..]

@ianatol
Copy link
Member

ianatol commented Aug 18, 2022

Fixed by #46388

@fonsp
Copy link
Member

fonsp commented Mar 13, 2023

For anyone running into this issue: a simple workaround is to replace

while true

with a for loop that never completes, e.g.

for _i in Iterators.countfrom(1)

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 compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) priority This should be addressed urgently
Projects
None yet
Development

No branches or pull requests

10 participants