JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.68k stars 5.48k forks source link

Segmentation fault in codegen upon storing ghost value to PhiC node with unboxed type #52106

Open topolarity opened 11 months ago

topolarity commented 11 months ago
julia> versioninfo()
Julia Version 1.11.0-DEV.879
Commit 29d78fae21* (2023-11-09 15:04 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 12 × 12th Gen Intel(R) Core(TM) i7-1255U
  WORD_SIZE: 64
  LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
  Threads: 1 on 12 virtual cores
function phic_type11()
     local a
     try
         if Base.inferencebarrier(true)
             a = Base.inferencebarrier(true) ? missing : nothing
         else
             a = 1
             may_error(true)
         end
     catch
     end

     GC.gc()
     return a::Int
 end

 phic_type11()
 [2015] signal (11.1): Segmentation fault
in expression starting at REPL[11]:1
emit_memcpy_llvm at /home/topolarity/repos/julia/src/cgutils.cpp:999
emit_memcpy<llvm::Value*&> at /home/topolarity/repos/julia/src/cgutils.cpp:1080 [inlined]
emit_vi_assignment_unboxed at /home/topolarity/repos/julia/src/codegen.cpp:5165
operator() at /home/topolarity/repos/julia/src/codegen.cpp:5365 [inlined]
emit_guarded_test<emit_varinfo_assign(jl_codectx_t&, jl_varinfo_t&, jl_cgval_t, jl_value_t*, bool)::<lambda()> > at /home/topolarity/repos/julia/src/cgutils.cpp:1415 [inlined]
emit_varinfo_assign at /home/topolarity/repos/julia/src/codegen.cpp:5364
emit_upsilonnode at /home/topolarity/repos/julia/src/codegen.cpp:5423 [inlined]
emit_function at /home/topolarity/repos/julia/src/codegen.cpp:8614
jl_emit_code at /home/topolarity/repos/julia/src/codegen.cpp:8998
jl_emit_codeinst at /home/topolarity/repos/julia/src/codegen.cpp:9081
_jl_compile_codeinst at /home/topolarity/repos/julia/src/jitlayers.cpp:220
jl_generate_fptr_impl at /home/topolarity/repos/julia/src/jitlayers.cpp:525
jl_compile_method_internal at /home/topolarity/repos/julia/src/gf.c:2507
_jl_invoke at /home/topolarity/repos/julia/src/gf.c:2913
ijl_apply_generic at /home/topolarity/repos/julia/src/gf.c:3103
jl_apply at /home/topolarity/repos/julia/src/./julia.h:2130 [inlined]
do_call at /home/topolarity/repos/julia/src/interpreter.c:126
eval_stmt_value at /home/topolarity/repos/julia/src/interpreter.c:174 [inlined]
eval_body at /home/topolarity/repos/julia/src/interpreter.c:629
jl_interpret_toplevel_thunk at /home/topolarity/repos/julia/src/interpreter.c:787
jl_toplevel_eval_flex at /home/topolarity/repos/julia/src/toplevel.c:938
jl_toplevel_eval_flex at /home/topolarity/repos/julia/src/toplevel.c:881
ijl_toplevel_eval at /home/topolarity/repos/julia/src/toplevel.c:947 [inlined]
ijl_toplevel_eval_in at /home/topolarity/repos/julia/src/toplevel.c:989
eval at ./boot.jl:418 [inlined]
eval_user_input at /home/topolarity/repos/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:167
repl_backend_loop at /home/topolarity/repos/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:263
#start_repl_backend#48 at /home/topolarity/repos/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:248
start_repl_backend at /home/topolarity/repos/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:245
_jl_invoke at /home/topolarity/repos/julia/src/gf.c:0
ijl_apply_generic at /home/topolarity/repos/julia/src/gf.c:3103
#run_repl#61 at /home/topolarity/repos/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:404
run_repl at /home/topolarity/repos/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:390
unknown function (ip: 0x7fc294193d89)
_jl_invoke at /home/topolarity/repos/julia/src/gf.c:0
ijl_apply_generic at /home/topolarity/repos/julia/src/gf.c:3103
#1077 at ./client.jl:441
jfptr_YY.1077_14546 at /home/topolarity/repos/julia/usr/share/julia/compiled/v1.11/REPL/u0gqU_XPcpv.so (unknown line)
_jl_invoke at /home/topolarity/repos/julia/src/gf.c:0
ijl_apply_generic at /home/topolarity/repos/julia/src/gf.c:3103
jl_apply at /home/topolarity/repos/julia/src/./julia.h:2130 [inlined]
jl_f__call_latest at /home/topolarity/repos/julia/src/builtins.c:859
#invokelatest#2 at ./essentials.jl:929 [inlined]
invokelatest at ./essentials.jl:926 [inlined]
run_main_repl at ./client.jl:425
repl_main at ./client.jl:604 [inlined]
_start at ./client.jl:578
jfptr__start_66248 at /home/topolarity/repos/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at /home/topolarity/repos/julia/src/gf.c:0
ijl_apply_generic at /home/topolarity/repos/julia/src/gf.c:3103
jl_apply at /home/topolarity/repos/julia/src/./julia.h:2130 [inlined]
true_main at /home/topolarity/repos/julia/src/jlapi.c:586
jl_repl_entrypoint at /home/topolarity/repos/julia/src/jlapi.c:738
main at /home/topolarity/repos/julia/cli/loader_exe.c:58
Allocations: 5643378 (Pool: 5642734; Big: 644); GC: 10
[1]    2015 segmentation fault  ./julia
topolarity commented 11 months ago

Huge thanks to @gbaraldi for guiding me through codegen to surface this one.