Julia: Segfault on compile in ApproxFun

Created on 20 Jul 2018  Â·  8Comments  Â·  Source: JuliaLang/julia

This is on the branch "bug-crashoncompile" of ApproxFun in Julia v0.7-beta.

I am also on master for FastGaussQuadrature.jl, and FastTransforms.jl (and also BandedMatrices.jl, BlockBandedMatrices.jl but those the tagged versions support Julia v0.7).

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-beta2.32 (2018-07-17 20:09 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit b6a60dd660* (2 days old master)
|__/                   |  x86_64-apple-darwin17.6.0

julia> using ApproxFun, Test

julia> x = Fun(0 .. 1); f = sqrt(x); sp = space(f) ∪ ConstantSpace(); cfsin = f.coefficients; A = space(f); B = sp;

julia> precompile(ApproxFun.defaultcoefficients, (typeof(cfsin), typeof(A), typeof(B)))

signal (11): Segmentation fault: 11
in expression starting at no file:0
bug

Most helpful comment

Minimal reduction:

julia> function foo()
           x = (1, 2)
           if rand() < 0.5
               if rand() < 0.5
                   y = nothing
               else
                   y = missing
               end
               x = y
           end
           x
       end
foo (generic function with 1 method)

julia> foo()

signal (11): Segmentation fault
in expression starting at no file:0
getType at /home/keno/julia/usr/include/llvm/IR/Value.h:245
maybe_bitcast at /home/keno/julia/src/cgutils.cpp:460
emit_unionmove at /home/keno/julia/src/cgutils.cpp:2292
emit_function at /home/keno/julia/src/codegen.cpp:6461
jl_compile_linfo at /home/keno/julia/src/codegen.cpp:1160
jl_compile_method_internal at /home/keno/julia/src/gf.c:1777
jl_fptr_trampoline at /home/keno/julia/src/gf.c:1811
jl_apply_generic at /home/keno/julia/src/gf.c:2165
do_call at /home/keno/julia/src/interpreter.c:324
eval_value at /home/keno/julia/src/interpreter.c:428
eval_stmt_value at /home/keno/julia/src/interpreter.c:363
eval_body at /home/keno/julia/src/interpreter.c:683
jl_interpret_toplevel_thunk_callback at /home/keno/julia/src/interpreter.c:800
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f219744b1bf)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /home/keno/julia/src/interpreter.c:809
jl_toplevel_eval_flex at /home/keno/julia/src/toplevel.c:822
jl_toplevel_eval at /home/keno/julia/src/toplevel.c:831
jl_toplevel_eval_in at /home/keno/julia/src/builtins.c:633
eval at ./boot.jl:319
jl_fptr_args at /home/keno/julia/src/gf.c:1822
jl_apply_generic at /home/keno/julia/src/gf.c:2165
eval_user_input at /home/keno/julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:87
macro expansion at /home/keno/julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:119 [inlined]
#28 at ./task.jl:262
jl_fptr_args at /home/keno/julia/src/gf.c:1822
jl_fptr_trampoline at /home/keno/julia/src/gf.c:1812
jl_apply_generic at /home/keno/julia/src/gf.c:2165
jl_apply at /home/keno/julia/src/julia.h:1538
start_task at /home/keno/julia/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
Allocations: 4833687 (Pool: 4832774; Big: 913); GC: 9
Segmentation fault

All 8 comments

I get this stack trace:

emit_unionmove at /home/jeff/src/julia/src/cgutils.cpp:2261
emit_function at /home/jeff/src/julia/src/codegen.cpp:6449
jl_compile_linfo at /home/jeff/src/julia/src/codegen.cpp:1159
emit_invoke at /home/jeff/src/julia/src/codegen.cpp:3083
emit_expr at /home/jeff/src/julia/src/codegen.cpp:3882
emit_ssaval_assign at /home/jeff/src/julia/src/codegen.cpp:3604
emit_stmtpos at /home/jeff/src/julia/src/codegen.cpp:3790 [inlined]
emit_function at /home/jeff/src/julia/src/codegen.cpp:6238
jl_compile_linfo at /home/jeff/src/julia/src/codegen.cpp:1159

Also, I don't think it's related but these packages hit pathological cases in subtyping that cause very high load times. It's caused by the large StridedArray union type. I believe there is already some awareness of this problem. In the meantime I'll see if I can improve the subtyping code for this case.

I was at one point hoping to make a PR to deprecate StridedArray, but the second PR in that direction to redesign mul! got bogged down by design discussions so never got merged.

PS Apart from this Segfault, ApproxFun now passes all tests without errors/warnings 🎉

This might have been the same issue, but in Julia v0.6: https://github.com/JuliaLang/julia/issues/23792

What is the severity of this --- does it render the package unusable, or is it a rare case?

Lots of code funnels through defaultcoefficients so I’d say unusable, though large chunks of ApproxFun still work.

Minimal reduction:

julia> function foo()
           x = (1, 2)
           if rand() < 0.5
               if rand() < 0.5
                   y = nothing
               else
                   y = missing
               end
               x = y
           end
           x
       end
foo (generic function with 1 method)

julia> foo()

signal (11): Segmentation fault
in expression starting at no file:0
getType at /home/keno/julia/usr/include/llvm/IR/Value.h:245
maybe_bitcast at /home/keno/julia/src/cgutils.cpp:460
emit_unionmove at /home/keno/julia/src/cgutils.cpp:2292
emit_function at /home/keno/julia/src/codegen.cpp:6461
jl_compile_linfo at /home/keno/julia/src/codegen.cpp:1160
jl_compile_method_internal at /home/keno/julia/src/gf.c:1777
jl_fptr_trampoline at /home/keno/julia/src/gf.c:1811
jl_apply_generic at /home/keno/julia/src/gf.c:2165
do_call at /home/keno/julia/src/interpreter.c:324
eval_value at /home/keno/julia/src/interpreter.c:428
eval_stmt_value at /home/keno/julia/src/interpreter.c:363
eval_body at /home/keno/julia/src/interpreter.c:683
jl_interpret_toplevel_thunk_callback at /home/keno/julia/src/interpreter.c:800
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f219744b1bf)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /home/keno/julia/src/interpreter.c:809
jl_toplevel_eval_flex at /home/keno/julia/src/toplevel.c:822
jl_toplevel_eval at /home/keno/julia/src/toplevel.c:831
jl_toplevel_eval_in at /home/keno/julia/src/builtins.c:633
eval at ./boot.jl:319
jl_fptr_args at /home/keno/julia/src/gf.c:1822
jl_apply_generic at /home/keno/julia/src/gf.c:2165
eval_user_input at /home/keno/julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:87
macro expansion at /home/keno/julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:119 [inlined]
#28 at ./task.jl:262
jl_fptr_args at /home/keno/julia/src/gf.c:1822
jl_fptr_trampoline at /home/keno/julia/src/gf.c:1812
jl_apply_generic at /home/keno/julia/src/gf.c:2165
jl_apply at /home/keno/julia/src/julia.h:1538
start_task at /home/keno/julia/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
Allocations: 4833687 (Pool: 4832774; Big: 913); GC: 9
Segmentation fault
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yurivish picture yurivish  Â·  3Comments

omus picture omus  Â·  3Comments

musm picture musm  Â·  3Comments

sbromberger picture sbromberger  Â·  3Comments

TotalVerb picture TotalVerb  Â·  3Comments