julia> @code_native unique([Tuple(1:65)])
signal (11): Segmentation fault: 11
in expression starting at REPL[4]:1
_ZL31combineInstructionsOverFunctionRN4llvm8FunctionERNS_19InstCombineWorklistEPNS_9AAResultsERNS_15AssumptionCacheERNS_17TargetLibraryInfoERNS_13DominatorTreeERNS_25OptimizationRemarkEmitterEPNS_18BlockFrequencyInfoEPNS_18ProfileSummaryInfoEbPNS_8LoopInfoE at /Users/ericdavies/repos/julia1p5/usr/lib/libLLVM.dylib (unknown line)
_ZN4llvm24InstructionCombiningPass13runOnFunctionERNS_8FunctionE at /Users/ericdavies/repos/julia1p5/usr/lib/libLLVM.dylib (unknown line)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /Users/ericdavies/repos/julia1p5/usr/lib/libLLVM.dylib (unknown line)
_ZN12_GLOBAL__N_113CGPassManager11runOnModuleERN4llvm6ModuleE at /Users/ericdavies/repos/julia1p5/usr/lib/libLLVM.dylib (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /Users/ericdavies/repos/julia1p5/usr/lib/libLLVM.dylib (unknown line)
operator() at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:0
addModule at /Users/ericdavies/repos/julia1p5/usr/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h:93
addModule at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:648
jl_add_to_ee at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:893 [inlined]
jl_add_to_ee at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:955
jl_add_to_ee at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:977 [inlined]
_jl_compile_codeinst at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:126
jl_generate_fptr at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:302
jl_dump_method_asm at /Users/ericdavies/repos/julia1p5/src/jitlayers.cpp:355
_dump_function_linfo_native at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/InteractiveUtils/src/codeview.jl:103 [inlined]
_dump_function at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/InteractiveUtils/src/codeview.jl:85
_dump_function at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/InteractiveUtils/src/codeview.jl:71 [inlined]
#code_native#30 at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/InteractiveUtils/src/codeview.jl:154 [inlined]
code_native##kw at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/InteractiveUtils/src/codeview.jl:154
unknown function (ip: 0x108ed4ca5)
#code_native#31 at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/InteractiveUtils/src/codeview.jl:156
code_native at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/InteractiveUtils/src/codeview.jl:156
jl_apply at /Users/ericdavies/repos/julia1p5/src/./julia.h:1690 [inlined]
do_call at /Users/ericdavies/repos/julia1p5/src/interpreter.c:117
eval_body at /Users/ericdavies/repos/julia1p5/src/interpreter.c:0
jl_interpret_toplevel_thunk at /Users/ericdavies/repos/julia1p5/src/interpreter.c:660
jl_toplevel_eval_flex at /Users/ericdavies/repos/julia1p5/src/toplevel.c:840
jl_toplevel_eval_flex at /Users/ericdavies/repos/julia1p5/src/toplevel.c:790
jl_toplevel_eval at /Users/ericdavies/repos/julia1p5/src/toplevel.c:849 [inlined]
jl_toplevel_eval_in at /Users/ericdavies/repos/julia1p5/src/toplevel.c:883
eval at ./boot.jl:331
eval_user_input at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:134
repl_backend_loop at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:195
start_repl_backend at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:180
#run_repl#37 at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:292
run_repl at /Users/ericdavies/repos/julia1p5/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288
#803 at ./client.jl:399
jfptr_YY.803_38021 at /Users/ericdavies/repos/julia1p5/usr/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/ericdavies/repos/julia1p5/src/./julia.h:1690 [inlined]
do_apply at /Users/ericdavies/repos/julia1p5/src/builtins.c:655
jl_f__apply at /Users/ericdavies/repos/julia1p5/src/builtins.c:669 [inlined]
jl_f__apply_latest at /Users/ericdavies/repos/julia1p5/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_52415 at /Users/ericdavies/repos/julia1p5/usr/lib/julia/sys.dylib (unknown line)
true_main at /Users/ericdavies/repos/julia1p5/julia (unknown line)
main at /Users/ericdavies/repos/julia1p5/julia (unknown line)
Allocations: 8439658 (Pool: 8437395; Big: 2263); GC: 10
fish: Job 1, '~/repos/julia1p5/julia $argv' terminated by signal SIGSEGV (Address boundary error)
This was on the latest release-1.5 branch. It also happens on 1.4 but not on 1.3
65 seems to be the minimum size to trigger the segfault
Hmmmm....this might be the cause of https://github.com/JuliaData/CSV.jl/issues/635 as well that I've been trying to reduce.
Reduced a bit:
julia> code_llvm(Base.ht_keyindex, (Dict{NTuple{65,Int64},Nothing}, NTuple{65,Int64}))
signal (11): Segmentation fault
Might have to do with LLVM vectors longer than 64 elements.
I'm seeing probably malformed IR?
julia> code_llvm(Base.ht_keyindex, (Dict{NTuple{65,Int64},Nothing}, NTuple{65,Int64}), optimize=false, raw=true, dump_module=true)
signal (11): Segmentation fault
in expression starting at REPL[1]:1
_ZN12_GLOBAL__N_114AssemblyWriter19writeOperandBundlesEPKN4llvm8CallBaseE at /data/vtjnash/julia1/usr/bin/../lib/libLLVM-9jl.so (unknown line)
_ZN12_GLOBAL__N_114AssemblyWriter16printInstructionERKN4llvm11InstructionE at /data/vtjnash/julia1/usr/bin/../lib/libLLVM-9jl.so (unknown line)
_ZN12_GLOBAL__N_114AssemblyWriter15printBasicBlockEPKN4llvm10BasicBlockE at /data/vtjnash/julia1/usr/bin/../lib/libLLVM-9jl.so (unknown line)
_ZN12_GLOBAL__N_114AssemblyWriter13printFunctionEPKN4llvm8FunctionE at /data/vtjnash/julia1/usr/bin/../lib/libLLVM-9jl.so (unknown line)
_ZNK4llvm6Module5printERNS_11raw_ostreamEPNS_24AssemblyAnnotationWriterEbb at /data/vtjnash/julia1/usr/bin/../lib/libLLVM-9jl.so (unknown line)
jl_dump_function_ir at /data/vtjnash/julia1/src/disasm.cpp:458
Here's the fix, just needs this added as a test case and a PR:
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 5fecee611e..ee3588f320 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -2352,7 +2352,7 @@ static Value *emit_bits_compare(jl_codectx_t &ctx, jl_cgval_t arg1, jl_cgval_t a
nroots++;
if ((gc_uses[nroots] = get_gc_root_for(arg2)))
nroots++;
- OperandBundleDef OpBundle("jl_roots", gc_uses);
+ OperandBundleDef OpBundle("jl_roots", makeArrayRef(gc_uses, nroots));
Value *answer = ctx.builder.CreateCall(prepare_call(memcmp_func), {
ctx.builder.CreateBitCast(varg1, T_pint8),
ctx.builder.CreateBitCast(varg2, T_pint8),
Most helpful comment
Here's the fix, just needs this added as a test case and a PR: