Julia-1.0.3 segfaults on this snippet, while julia-0.7 runs fine


#1
julia> versioninfo()
Julia Version 0.7.0
Commit a4cb80f3ed (2018-08-08 06:46 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 2

julia> function ifelsetuple(n::Integer, k::Integer, f, g)
           return ntuple(i -> (i <= k ? f : g), n)
       end
ifelsetuple (generic function with 1 method)

julia> f(x) = x^2; g(x) = x^3; ifelsetuple(5, 3, f, g)
(f, f, f, g, g)

julia> a = [1]; b=[2]; ifelsetuple(5, 3, a, b)
([1], [1], [1], [2], [2])
julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 2

julia> function ifelsetuple(n::Integer, k::Integer, f, g)
           return ntuple(i -> (i <= k ? f : g), n)
       end
ifelsetuple (generic function with 1 method)

julia> f(x) = x^2; g(x) = x^3; ifelsetuple(5, 3, f, g)
(f, f, f, g, g)

julia> a = [1]; b=[2]; ifelsetuple(5, 3, a, b)

signal (11): Segmentation fault
in expression starting at no file:0
_ZN4llvm9LiveRange4joinERS0_PKiS3_RNS_15SmallVectorImplIPNS_6VNInfoEEE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
_ZN12_GLOBAL__N_117RegisterCoalescer12joinVirtRegsERN4llvm13CoalescerPairE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
_ZN12_GLOBAL__N_117RegisterCoalescer20copyCoalesceWorkListEN4llvm15MutableArrayRefIPNS1_12MachineInstrEEE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
_ZN12_GLOBAL__N_117RegisterCoalescer20runOnMachineFunctionERN4llvm15MachineFunctionE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /opt/julia-1.0.3/bin/../lib/julia/libLLVM-6.0.so (unknown line)
operator() at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:481
addModule at /buildworker/worker/package_linux64/build/usr/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h:57 [inlined]
addModule at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:608
jl_add_to_ee at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:855 [inlined]
jl_finalize_function at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:863
getAddressForFunction at /buildworker/worker/package_linux64/build/src/codegen.cpp:1299
jl_generate_fptr at /buildworker/worker/package_linux64/build/src/codegen.cpp:1408
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1823 [inlined]
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1830
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2184
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:324
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:430
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:363 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:682
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:806
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f5ce2e2cfaf)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:815
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:805
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:754
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/builtins.c:622
eval at ./boot.jl:319
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2184
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:85
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:259
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2184
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1537 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
Allocations: 4935311 (Pool: 4934051; Big: 1260); GC: 10
[1]    1657 segmentation fault (core dumped)  julia-1.0.3

should I file a bug, or is this code silently (i.e. without warnings) violating some julia-1.0 assumptions?


#2

No reason this should not work, please open an issue https://github.com/JuliaLang/julia/issues/new


#3