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

0.5: Illegal instruction 4 #17003

Closed
dlfivefifty opened this issue Jun 18, 2016 · 50 comments
Closed

0.5: Illegal instruction 4 #17003

dlfivefifty opened this issue Jun 18, 2016 · 50 comments
Labels
bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference
Milestone

Comments

@dlfivefifty
Copy link
Contributor

dlfivefifty commented Jun 18, 2016

Yet another ApproxFun segfault, that only appears when running all the tests (so hard to isolate).

There's some bizarre behaviour when running the line in question, but does not immediately cause the segfault. I'll try to narrow down the issue.

Julia Version 0.5.0-dev+4850
Commit 9ae4520 (2016-06-18 03:25 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin15.5.0)
  CPU: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libgfortblas
  LAPACK: liblapack
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)
Pkg.checkout("ApproxFun","bug-illinstruct")
Pkg.test("ApproxFun")

signal (4): Illegal instruction: 4
while loading /Users/solver/.julia/v0.5/ApproxFun/test/PDETest.jl, in expression starting on line 16
kron at /Users/solver/.julia/v0.5/ApproxFun/src/PDE/KroneckerOperator.jl:295
dirichlet at /Users/solver/.julia/v0.5/ApproxFun/src/PDE/PDE.jl:49
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:86
do_call at /Users/solver/Projects/julia5/src/interpreter.c:65
eval at /Users/solver/Projects/julia5/src/interpreter.c:188
do_call at /Users/solver/Projects/julia5/src/interpreter.c:64
eval at /Users/solver/Projects/julia5/src/interpreter.c:188
eval_body at /Users/solver/Projects/julia5/src/interpreter.c:469
jl_interpret_call at /Users/solver/Projects/julia5/src/interpreter.c:573
jl_toplevel_eval_flex at /Users/solver/Projects/julia5/src/toplevel.c:543
jl_parse_eval_all at /Users/solver/Projects/julia5/src/ast.c:699
jl_load at /Users/solver/Projects/julia5/src/toplevel.c:569
include_from_node1 at ./loading.jl:426
unknown function (ip: 0x1115b453c)
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:86
do_call at /Users/solver/Projects/julia5/src/interpreter.c:65
eval at /Users/solver/Projects/julia5/src/interpreter.c:188
jl_toplevel_eval_flex at /Users/solver/Projects/julia5/src/toplevel.c:529
jl_parse_eval_all at /Users/solver/Projects/julia5/src/ast.c:699
jl_load at /Users/solver/Projects/julia5/src/toplevel.c:569
include_from_node1 at ./loading.jl:426
unknown function (ip: 0x1115b453c)
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:86
process_options at ./client.jl:266
_start at ./client.jl:322
unknown function (ip: 0x1115dfbc4)
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:86
true_main at /Users/solver/Projects/julia5/usr/bin/julia (unknown line)
main at /Users/solver/Projects/julia5/usr/bin/julia (unknown line)
Allocations: 429519734 (Pool: 429304528; Big: 215206); GC: 866
====================================================[ ERROR: ApproxFun ]====================================================

failed process: Process(`/Users/solver/Projects/julia5/usr/bin/julia -Cnative -J/Users/solver/Projects/julia5/usr/lib/julia/sys.dylib --compile=yes --depwarn=yes --check-bounds=yes --code-coverage=none --color=yes /Users/solver/.julia/v0.5/ApproxFun/test/runtests.jl`, ProcessSignaled(4)) [0]

============================================================================================================================
ERROR: ApproxFun had test errors
 in #test#49(::Bool, ::Function, ::Array{AbstractString,1}) at ./pkg/entry.jl:694
 in (::Base.Pkg.Entry.#kw##test)(::Array{Any,1}, ::Base.Pkg.Entry.#test, ::Array{AbstractString,1}) at ./null:0
 in (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#test,Tuple{Array{AbstractString,1}}})() at ./pkg/dir.jl:31
 in cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#test,Tuple{Array{AbstractString,1}}}, ::String) at ./file.jl:59
 in #cd#1(::Array{Any,1}, ::Function, ::Function, ::Array{AbstractString,1}, ::Vararg{Array{AbstractString,1},N}) at ./pkg/dir.jl:31
 in (::Base.Pkg.Dir.#kw##cd)(::Array{Any,1}, ::Base.Pkg.Dir.#cd, ::Function, ::Array{AbstractString,1}, ::Vararg{Array{AbstractString,1},N}) at ./null:0
 in #test#3(::Bool, ::Function, ::String, ::Vararg{String,N}) at ./pkg/pkg.jl:245
 in test(::String, ::Vararg{String,N}) at ./pkg/pkg.jl:245
 in eval(::Module, ::Any) at ./boot.jl:231
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
@dlfivefifty
Copy link
Contributor Author

Here's a non-crashing version of the inconsistency:

dirichlet(Interval()^2)

displays no output while

@code_typed dirichlet(Interval()^2)

shows that the return type is

Array{ApproxFun.Operator{BandedMatrices.BandedMatrix{Float64}},1})

@dlfivefifty
Copy link
Contributor Author

Nevermind, that is due to a questionable override of Base.writemime

@yuyichao
Copy link
Contributor

SIGILL is likely due to functions that returns unexpectedly. You could check @code_llvm (look for @llvm.trap) to figure out which function it was

@dlfivefifty
Copy link
Contributor Author

I managed to trigger it with a shorter sequence in julia-debug by running the following in a .jl file (running on command prompt or deleting lines does not trigger the crash!):

using ApproxFun

dx=dy=Interval()
d=dx*dy
x=Fun(identity,dx);y=Fun(identity,dy)

G=[real(exp(-1+1.0im*y));
                        real(exp(1+1im*y));
                        real(exp(x-1im));
                        real(exp(x+1im));0.];

A=[dirichlet(d);lap(d)]

Here's the versioninfo:

Julia Version 0.5.0-dev+4850
Commit 9ae4520 (2016-06-18 03:25 UTC)
DEBUG build
Platform Info:
  System: Darwin (x86_64-apple-darwin15.5.0)
  CPU: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libgfortblas
  LAPACK: liblapack
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)

@dlfivefifty
Copy link
Contributor Author

This is still present in the latest build. I tried working around it by changing the offending line from a comprehension to an explicit constructed array, but the bug remained.

@dlfivefifty
Copy link
Contributor Author

The latest build gives a bit more information: apparently a call to copy! is the trigger:

while loading /Users/solver/.julia/v0.5/ApproxFun/test/PDETest.jl, in expression starting on line 16
copy! at ./abstractarray.jl:393
kron at /Users/solver/.julia/v0.5/ApproxFun/src/PDE/KroneckerOperator.jl:298
dirichlet at /Users/solver/.julia/v0.5/ApproxFun/src/PDE/PDE.jl:49
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:177 [inlined]
jl_apply_generic at /Users/solver/Projects/julia5/src/gf.c:2034
do_call at /Users/solver/Projects/julia5/src/interpreter.c:66
eval at /Users/solver/Projects/julia5/src/interpreter.c:190
do_call at /Users/solver/Projects/julia5/src/interpreter.c:65
eval at /Users/solver/Projects/julia5/src/interpreter.c:190
eval_body at /Users/solver/Projects/julia5/src/interpreter.c:469
jl_interpret_call at /Users/solver/Projects/julia5/src/interpreter.c:573
jl_toplevel_eval_flex at /Users/solver/Projects/julia5/src/toplevel.c:572
jl_parse_eval_all at /Users/solver/Projects/julia5/src/ast.c:717
jl_load at /Users/solver/Projects/julia5/src/toplevel.c:596 [inlined]
jl_load_ at /Users/solver/Projects/julia5/src/toplevel.c:605
include_from_node1 at ./loading.jl:426
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:177 [inlined]
jl_apply_generic at /Users/solver/Projects/julia5/src/gf.c:2034
do_call at /Users/solver/Projects/julia5/src/interpreter.c:66
eval at /Users/solver/Projects/julia5/src/interpreter.c:190
jl_toplevel_eval_flex at /Users/solver/Projects/julia5/src/toplevel.c:558
jl_parse_eval_all at /Users/solver/Projects/julia5/src/ast.c:717
jl_load at /Users/solver/Projects/julia5/src/toplevel.c:596 [inlined]
jl_load_ at /Users/solver/Projects/julia5/src/toplevel.c:605
include_from_node1 at ./loading.jl:426
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:177 [inlined]
jl_apply_generic at /Users/solver/Projects/julia5/src/gf.c:2034
process_options at ./client.jl:262
_start at ./client.jl:318
jl_call_method_internal at /Users/solver/Projects/julia5/src/./julia_internal.h:177 [inlined]
jl_apply_generic at /Users/solver/Projects/julia5/src/gf.c:2034
true_main at /Users/solver/Projects/julia5/usr/bin/julia (unknown line)
main at /Users/solver/Projects/julia5/usr/bin/julia (unknown line)
Allocations: 480657994 (Pool: 480586587; Big: 71407); GC: 913

@ViralBShah
Copy link
Member

Would this be a regression that we need to fix for 0.5?

@dlfivefifty
Copy link
Contributor Author

Yes, it’s fine in 0.4 and it was actually working fine in 0.5 a month ago or so.

On 23 Jul 2016, at 9:13 AM, Viral B. Shah notifications@github.com wrote:

Would this be a regression that we need to fix for 0.5?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #17003 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ABLDqelH2KaQiPHgzJPc6vQMK8cOUNRGks5qYU6DgaJpZM4I47aR.

@yuyichao
Copy link
Contributor

See also my very early comment above #17003 (comment) if you are still seeing a sigill.

@dlfivefifty
Copy link
Contributor Author

I haven't been able to find @llvm.trap

@yuyichao
Copy link
Contributor

So what's the instruction it fails on in the debugger?

@dlfivefifty
Copy link
Contributor Author

I don't know how to use the debugger.

@dlfivefifty
Copy link
Contributor Author

dlfivefifty commented Jul 23, 2016

OK I brew installed gdb, and tried running the script but get the error

Unable to find Mach task port for process-id 54432: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

@dlfivefifty
Copy link
Contributor Author

OK I got it working, here is what bt returns:

Thread 1 received signal SIGILL, Illegal instruction.
0x000000030d276ab3 in ?? ()
(gdb) bt
#0  0x000000030d276ab3 in ?? ()
#1  0x00007fff5fbfd940 in ?? ()
#2  0xbff0000000000000 in ?? ()
#3  0x3ff0000000000000 in ?? ()
#4  0x0000000114752300 in ?? ()
#5  0x0000000000000000 in ?? ()

@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently regression Regression in behavior compared to a previous version labels Jul 23, 2016
@JeffBezanson JeffBezanson added this to the 0.5.x milestone Jul 23, 2016
@tkelman
Copy link
Contributor

tkelman commented Jul 23, 2016

try with julia-debug? and maybe lldb might work better than gdb on mac

@yuyichao
Copy link
Contributor

display/i $pc

@dlfivefifty
Copy link
Contributor Author

OK this is what lldb gives:

Process 18409 stopped
* thread #1: tid = 0x27d64, 0x000000030e5e90f9, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x000000030e5e90f9
->  0x30e5e90f9: ud2    
    0x30e5e90fb: nopl   (%rax,%rax)
    0x30e5e9100: pushq  %rbp
    0x30e5e9101: movq   %rsp, %rbp
(lldb) bt
* thread #1: tid = 0x27d64, 0x000000030e5e90f9, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x000000030e5e90f9
    frame #1: 0x000000030e5e9218
    frame #2: 0x000000030e5e7f86
    frame #3: 0x0000000100017e76 libjulia-debug.dylib`jl_call_method_internal(meth=0x0000000119a786d0, args=0x00007fff5fbfc4c0, nargs=2) + 198 at julia_internal.h:177
    frame #4: 0x000000010001b481 libjulia-debug.dylib`jl_apply_generic(args=0x00007fff5fbfc4c0, nargs=2) + 913 at gf.c:2034
    frame #5: 0x000000010003c005 libjulia-debug.dylib`do_call(args=0x0000000119c1d6d0, nargs=2, s=0x00007fff5fbfd4c0) + 245 at interpreter.c:66
    frame #6: 0x0000000100038d8e libjulia-debug.dylib`eval(e=0x000000011270c330, s=0x00007fff5fbfd4c0) + 1134 at interpreter.c:190
    frame #7: 0x000000010003bfd7 libjulia-debug.dylib`do_call(args=0x0000000117e40d70, nargs=3, s=0x00007fff5fbfd4c0) + 199 at interpreter.c:65
    frame #8: 0x0000000100038d8e libjulia-debug.dylib`eval(e=0x000000011270c310, s=0x00007fff5fbfd4c0) + 1134 at interpreter.c:190
    frame #9: 0x000000010003b130 libjulia-debug.dylib`eval_body(stmts=0x0000000117e40cc0, s=0x00007fff5fbfd4c0, start=0, toplevel=1) + 480 at interpreter.c:469
    frame #10: 0x000000010003bbb1 libjulia-debug.dylib`jl_interpret_call(lam=0x0000000119a78640, args=0x0000000000000000, nargs=0, sparam_vals=0x0000000000000000) + 577 at interpreter.c:573
    frame #11: 0x000000010003bd1c libjulia-debug.dylib`jl_interpret_toplevel_thunk(lam=0x0000000119a78640) + 44 at interpreter.c:580
    frame #12: 0x00000001000607dd libjulia-debug.dylib`jl_toplevel_eval_flex(e=0x000000011270c1f0, fast=1, expanded=1) + 2461 at toplevel.c:572
    frame #13: 0x0000000100029605 libjulia-debug.dylib`jl_parse_eval_all(fname="/Users/solver/.julia/v0.4/ApproxFun/test/PDETest.jl", content=0x0000000000000000, contentlen=0) + 1573 at ast.c:717
    frame #14: 0x000000010006159c libjulia-debug.dylib`jl_load(fname="/Users/solver/.julia/v0.4/ApproxFun/test/PDETest.jl") + 204 at toplevel.c:596
    frame #15: 0x000000010006163c libjulia-debug.dylib`jl_load_(str=0x0000000116edf480) + 108 at toplevel.c:605
    frame #16: 0x00000001041dda56 sys-debug.dylib`julia_include_from_node1_18759(#self#=<unavailable>, _path=String @ 0x0000000116edf400) + 966 at loading.jl:426 [opt]
    frame #17: 0x00000001041ddccc sys-debug.dylib`jlcall_include_from_node1_18759 + 12
    frame #18: 0x0000000100017e76 libjulia-debug.dylib`jl_call_method_internal(meth=0x000000010a989de0, args=0x00007fff5fbfddb0, nargs=2) + 198 at julia_internal.h:177
    frame #19: 0x000000010001b481 libjulia-debug.dylib`jl_apply_generic(args=0x00007fff5fbfddb0, nargs=2) + 913 at gf.c:2034
    frame #20: 0x000000010003c005 libjulia-debug.dylib`do_call(args=0x00000001191495b0, nargs=2, s=0x0000000000000000) + 245 at interpreter.c:66
    frame #21: 0x0000000100038d8e libjulia-debug.dylib`eval(e=0x0000000111794a70, s=0x0000000000000000) + 1134 at interpreter.c:190
    frame #22: 0x00000001000388f7 libjulia-debug.dylib`jl_interpret_toplevel_expr(e=0x0000000111794a70) + 39 at interpreter.c:31
    frame #23: 0x0000000100060732 libjulia-debug.dylib`jl_toplevel_eval_flex(e=0x0000000111794a70, fast=1, expanded=1) + 2290 at toplevel.c:558
    frame #24: 0x0000000100029605 libjulia-debug.dylib`jl_parse_eval_all(fname="/Users/solver/.julia/v0.4/ApproxFun/test/runtests.jl", content=0x0000000000000000, contentlen=0) + 1573 at ast.c:717
    frame #25: 0x000000010006159c libjulia-debug.dylib`jl_load(fname="/Users/solver/.julia/v0.4/ApproxFun/test/runtests.jl") + 204 at toplevel.c:596
    frame #26: 0x000000010006163c libjulia-debug.dylib`jl_load_(str=0x000000010b5a5030) + 108 at toplevel.c:605
    frame #27: 0x00000001041dda56 sys-debug.dylib`julia_include_from_node1_18759(#self#=<unavailable>, _path=String @ 0x000000010b5a4870) + 966 at loading.jl:426 [opt]
    frame #28: 0x00000001041ddccc sys-debug.dylib`jlcall_include_from_node1_18759 + 12
    frame #29: 0x0000000100017e76 libjulia-debug.dylib`jl_call_method_internal(meth=0x000000010a989de0, args=0x00007fff5fbfee50, nargs=2) + 198 at julia_internal.h:177
    frame #30: 0x000000010001b481 libjulia-debug.dylib`jl_apply_generic(args=0x00007fff5fbfee50, nargs=2) + 913 at gf.c:2034
    frame #31: 0x00000001042143e7 sys-debug.dylib`julia_process_options_19863(#self#=<unavailable>, opts=JLOptions @ 0x00007fff5fbff050) + 3159 at client.jl:262 [opt]
    frame #32: 0x00000001042169d4 sys-debug.dylib`julia__start_19857(#self#=<unavailable>) + 1828 at client.jl:318 [opt]
    frame #33: 0x0000000104217579 sys-debug.dylib`jlcall__start_19857 + 9
    frame #34: 0x0000000100017e76 libjulia-debug.dylib`jl_call_method_internal(meth=0x000000010a6c99f0, args=0x00007fff5fbff6e8, nargs=1) + 198 at julia_internal.h:177
    frame #35: 0x000000010001b481 libjulia-debug.dylib`jl_apply_generic(args=0x00007fff5fbff6e8, nargs=1) + 913 at gf.c:2034
    frame #36: 0x0000000100001579 julia-debug`jl_apply(args=0x00007fff5fbff6e8, nargs=1) + 41 at julia.h:1394
    frame #37: 0x00000001000011ca julia-debug`true_main(argc=1, argv=0x00007fff5fbff830) + 202 at repl.c:112
    frame #38: 0x00000001000010be julia-debug`main(argc=1, argv=0x00007fff5fbff830) + 174 at repl.c:232
    frame #39: 0x0000000100000fb4 julia-debug`start + 52

@yuyichao
Copy link
Contributor

So it is a llvm.trap. Which function did you look for it in the code_llvm?

@dlfivefifty
Copy link
Contributor Author

I tried calling it on dirichlet(d). I'll try to unwrap it a bit to see whether I can narrow down the call. The @code_llvm result is as follows:

; Function Attrs: sspreq
define %jl_value_t* @julia_dirichlet_70426(%jl_value_t*, %jl_value_t**, i32) #0 {
if:
  %.sroa.370 = alloca [7 x i8], align 1
  %.sroa.354 = alloca [7 x i8], align 1
  %.sroa.330 = alloca [7 x i8], align 1
  %.sroa.314 = alloca [7 x i8], align 1
  %3 = alloca %jl_value_t**, align 8
  store volatile %jl_value_t** %1, %jl_value_t*** %3, align 8
  %4 = call %jl_value_t*** @jl_get_ptls_states() #1
  %gcrootframe7 = alloca [17 x %jl_value_t*], align 8
  %gcrootframe7.sub = getelementptr inbounds [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 0
  %temproots = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 11
  %5 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 14
  %6 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 2
  %7 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 3
  %8 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 4
  %9 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 5
  %10 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 10
  %11 = bitcast %jl_value_t** %temproots to i8*
  call void @llvm.memset.p0i8.i32(i8* %11, i8 0, i32 48, i32 8, i1 false)
  %12 = bitcast [17 x %jl_value_t*]* %gcrootframe7 to i64*
  %13 = bitcast %jl_value_t** %6 to i8*
  call void @llvm.memset.p0i8.i64(i8* %13, i8 0, i64 64, i32 8, i1 false)
  store i64 30, i64* %12, align 8
  %14 = bitcast %jl_value_t*** %4 to i64*
  %15 = load i64, i64* %14, align 8
  %16 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 1
  %17 = bitcast %jl_value_t** %16 to i64*
  store i64 %15, i64* %17, align 8
  store %jl_value_t** %gcrootframe7.sub, %jl_value_t*** %4, align 8
  store %jl_value_t* null, %jl_value_t** %10, align 8
  %18 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 12
  %19 = bitcast %jl_value_t** %1 to [2 x %Interval]**
  %20 = load [2 x %Interval]*, [2 x %Interval]** %19, align 8
  %21 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 13
  %22 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 15
  %23 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 16
  %24 = load [2 x %Interval], [2 x %Interval]* %20, align 16
  %.fca.0.0.extract = extractvalue [2 x %Interval] %24, 0, 0
  %.fca.0.1.extract = extractvalue [2 x %Interval] %24, 0, 1
  store %jl_value_t* inttoptr (i64 4490635800 to %jl_value_t*), %jl_value_t** %temproots, align 8
  %25 = bitcast %jl_value_t*** %4 to i8*
  %26 = getelementptr %jl_value_t**, %jl_value_t*** %4, i64 179
  %27 = bitcast %jl_value_t*** %26 to i8*
  %28 = call %jl_value_t* @jl_gc_pool_alloc(i8* %25, i8* %27, i32 48, i32 16328)
  %29 = getelementptr inbounds %jl_value_t, %jl_value_t* %28, i64 -1, i32 0
  store %jl_value_t* inttoptr (i64 4659791088 to %jl_value_t*), %jl_value_t** %29, align 8
  %30 = bitcast %jl_value_t* %28 to double*
  store double %.fca.0.0.extract, double* %30, align 8
  %.sroa.010.sroa.2.0..sroa.010.0..sroa_cast.sroa_idx24 = getelementptr inbounds %jl_value_t, %jl_value_t* %28, i64 1
  %31 = bitcast %jl_value_t* %.sroa.010.sroa.2.0..sroa.010.0..sroa_cast.sroa_idx24 to double*
  store double %.fca.0.1.extract, double* %31, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds %jl_value_t, %jl_value_t* %28, i64 2
  %.sroa.2.0..sroa_cast = bitcast %jl_value_t* %.sroa.2.0..sroa_idx to i8*
  store i8 0, i8* %.sroa.2.0..sroa_cast, align 8
  %.sroa.314.0..sroa_raw_cast = bitcast %jl_value_t* %28 to i8*
  %.sroa.314.0..sroa_raw_idx = getelementptr inbounds i8, i8* %.sroa.314.0..sroa_raw_cast, i64 17
  %.sroa.314.0..sroa_idx = getelementptr inbounds [7 x i8], [7 x i8]* %.sroa.314, i64 0, i64 0
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %.sroa.314.0..sroa_raw_idx, i8* %.sroa.314.0..sroa_idx, i64 7, i32 1, i1 false)
  %.sroa.315.0..sroa_idx16 = getelementptr inbounds %jl_value_t, %jl_value_t* %28, i64 3
  %.sroa.315.0..sroa_cast = bitcast %jl_value_t* %.sroa.315.0..sroa_idx16 to i64*
  store i64 0, i64* %.sroa.315.0..sroa_cast, align 8
  store %jl_value_t* %28, %jl_value_t** %18, align 8
  %32 = call %jl_value_t* @jl_gc_pool_alloc(i8* %25, i8* %27, i32 48, i32 16328)
  %33 = getelementptr inbounds %jl_value_t, %jl_value_t* %32, i64 -1, i32 0
  store %jl_value_t* inttoptr (i64 4659791088 to %jl_value_t*), %jl_value_t** %33, align 8
  %34 = bitcast %jl_value_t* %32 to double*
  store double %.fca.0.0.extract, double* %34, align 8
  %.sroa.025.sroa.2.0..sroa.025.0..sroa_cast.sroa_idx40 = getelementptr inbounds %jl_value_t, %jl_value_t* %32, i64 1
  %35 = bitcast %jl_value_t* %.sroa.025.sroa.2.0..sroa.025.0..sroa_cast.sroa_idx40 to double*
  store double %.fca.0.1.extract, double* %35, align 8
  %.sroa.229.0..sroa_idx = getelementptr inbounds %jl_value_t, %jl_value_t* %32, i64 2
  %.sroa.229.0..sroa_cast = bitcast %jl_value_t* %.sroa.229.0..sroa_idx to i8*
  store i8 1, i8* %.sroa.229.0..sroa_cast, align 8
  %.sroa.330.0..sroa_raw_cast = bitcast %jl_value_t* %32 to i8*
  %.sroa.330.0..sroa_raw_idx = getelementptr inbounds i8, i8* %.sroa.330.0..sroa_raw_cast, i64 17
  %.sroa.330.0..sroa_idx = getelementptr inbounds [7 x i8], [7 x i8]* %.sroa.330, i64 0, i64 0
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %.sroa.330.0..sroa_raw_idx, i8* %.sroa.330.0..sroa_idx, i64 7, i32 1, i1 false)
  %.sroa.331.0..sroa_idx32 = getelementptr inbounds %jl_value_t, %jl_value_t* %32, i64 3
  %.sroa.331.0..sroa_cast = bitcast %jl_value_t* %.sroa.331.0..sroa_idx32 to i64*
  store i64 0, i64* %.sroa.331.0..sroa_cast, align 8
  store %jl_value_t* %32, %jl_value_t** %21, align 8
  %36 = call %jl_value_t* @jl_invoke(%jl_value_t* inttoptr (i64 4807324624 to %jl_value_t*), %jl_value_t** %temproots, i32 3)
  store %jl_value_t* %36, %jl_value_t** %7, align 8
  %37 = load [2 x %Interval], [2 x %Interval]* %20, align 16
  %.fca.1.0.extract43 = extractvalue [2 x %Interval] %37, 1, 0
  %.fca.1.1.extract44 = extractvalue [2 x %Interval] %37, 1, 1
  store %jl_value_t* inttoptr (i64 4490635800 to %jl_value_t*), %jl_value_t** %5, align 8
  %38 = call %jl_value_t* @jl_gc_pool_alloc(i8* %25, i8* %27, i32 48, i32 16328)
  %39 = getelementptr inbounds %jl_value_t, %jl_value_t* %38, i64 -1, i32 0
  store %jl_value_t* inttoptr (i64 4659791088 to %jl_value_t*), %jl_value_t** %39, align 8
  %40 = bitcast %jl_value_t* %38 to double*
  store double %.fca.1.0.extract43, double* %40, align 8
  %.sroa.049.sroa.2.0..sroa.049.0..sroa_cast.sroa_idx64 = getelementptr inbounds %jl_value_t, %jl_value_t* %38, i64 1
  %41 = bitcast %jl_value_t* %.sroa.049.sroa.2.0..sroa.049.0..sroa_cast.sroa_idx64 to double*
  store double %.fca.1.1.extract44, double* %41, align 8
  %.sroa.253.0..sroa_idx = getelementptr inbounds %jl_value_t, %jl_value_t* %38, i64 2
  %.sroa.253.0..sroa_cast = bitcast %jl_value_t* %.sroa.253.0..sroa_idx to i8*
  store i8 0, i8* %.sroa.253.0..sroa_cast, align 8
  %.sroa.354.0..sroa_raw_cast = bitcast %jl_value_t* %38 to i8*
  %.sroa.354.0..sroa_raw_idx = getelementptr inbounds i8, i8* %.sroa.354.0..sroa_raw_cast, i64 17
  %.sroa.354.0..sroa_idx = getelementptr inbounds [7 x i8], [7 x i8]* %.sroa.354, i64 0, i64 0
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %.sroa.354.0..sroa_raw_idx, i8* %.sroa.354.0..sroa_idx, i64 7, i32 1, i1 false)
  %.sroa.355.0..sroa_idx56 = getelementptr inbounds %jl_value_t, %jl_value_t* %38, i64 3
  %.sroa.355.0..sroa_cast = bitcast %jl_value_t* %.sroa.355.0..sroa_idx56 to i64*
  store i64 0, i64* %.sroa.355.0..sroa_cast, align 8
  store %jl_value_t* %38, %jl_value_t** %22, align 8
  %42 = call %jl_value_t* @jl_gc_pool_alloc(i8* %25, i8* %27, i32 48, i32 16328)
  %43 = getelementptr inbounds %jl_value_t, %jl_value_t* %42, i64 -1, i32 0
  store %jl_value_t* inttoptr (i64 4659791088 to %jl_value_t*), %jl_value_t** %43, align 8
  %44 = bitcast %jl_value_t* %42 to double*
  store double %.fca.1.0.extract43, double* %44, align 8
  %.sroa.065.sroa.2.0..sroa.065.0..sroa_cast.sroa_idx80 = getelementptr inbounds %jl_value_t, %jl_value_t* %42, i64 1
  %45 = bitcast %jl_value_t* %.sroa.065.sroa.2.0..sroa.065.0..sroa_cast.sroa_idx80 to double*
  store double %.fca.1.1.extract44, double* %45, align 8
  %.sroa.269.0..sroa_idx = getelementptr inbounds %jl_value_t, %jl_value_t* %42, i64 2
  %.sroa.269.0..sroa_cast = bitcast %jl_value_t* %.sroa.269.0..sroa_idx to i8*
  store i8 1, i8* %.sroa.269.0..sroa_cast, align 8
  %.sroa.370.0..sroa_raw_cast = bitcast %jl_value_t* %42 to i8*
  %.sroa.370.0..sroa_raw_idx = getelementptr inbounds i8, i8* %.sroa.370.0..sroa_raw_cast, i64 17
  %.sroa.370.0..sroa_idx = getelementptr inbounds [7 x i8], [7 x i8]* %.sroa.370, i64 0, i64 0
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %.sroa.370.0..sroa_raw_idx, i8* %.sroa.370.0..sroa_idx, i64 7, i32 1, i1 false)
  %.sroa.371.0..sroa_idx72 = getelementptr inbounds %jl_value_t, %jl_value_t* %42, i64 3
  %.sroa.371.0..sroa_cast = bitcast %jl_value_t* %.sroa.371.0..sroa_idx72 to i64*
  store i64 0, i64* %.sroa.371.0..sroa_cast, align 8
  store %jl_value_t* %42, %jl_value_t** %23, align 8
  %46 = call %jl_value_t* @jl_invoke(%jl_value_t* inttoptr (i64 4807324624 to %jl_value_t*), %jl_value_t** %5, i32 3)
  store %jl_value_t* %46, %jl_value_t** %8, align 8
  store %jl_value_t* %36, %jl_value_t** %9, align 8
  %47 = getelementptr inbounds %jl_value_t, %jl_value_t* %36, i64 3, i32 0
  %48 = bitcast %jl_value_t** %47 to i64*
  %49 = load i64, i64* %48, align 8
  %50 = icmp sgt i64 %49, 0
  br i1 %50, label %L2, label %if4

L2:                                               ; preds = %if
  %51 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 7
  store %jl_value_t* %46, %jl_value_t** %51, align 8
  %52 = getelementptr inbounds %jl_value_t, %jl_value_t* %46, i64 3, i32 0
  %53 = bitcast %jl_value_t** %52 to i64*
  %54 = load i64, i64* %53, align 8
  %55 = icmp sgt i64 %54, 0
  br i1 %55, label %L3, label %if5

L3:                                               ; preds = %L2
  %56 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 9
  store %jl_value_t* %36, %jl_value_t** %56, align 8
  %57 = call %jl_value_t* @julia_kron_70430(%jl_value_t* %36, %UniformScaling* inttoptr (i64 4534667584 to %UniformScaling*)) #5
  store %jl_value_t* %57, %jl_value_t** %temproots, align 8
  store %jl_value_t* %46, %jl_value_t** %10, align 8
  %58 = call %jl_value_t* @julia_kron_70427(%UniformScaling* inttoptr (i64 4534667584 to %UniformScaling*), %jl_value_t* %46) #5
  store %jl_value_t* %58, %jl_value_t** %18, align 8
  %59 = call %jl_value_t* @julia_vcat_70433(%jl_value_t* inttoptr (i64 4495668256 to %jl_value_t*), %jl_value_t** %temproots, i32 2)
  %60 = load i64, i64* %17, align 8
  store i64 %60, i64* %14, align 8
  ret %jl_value_t* %59

if4:                                              ; preds = %if
  %61 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 6
  store %jl_value_t* %46, %jl_value_t** %61, align 8
  %62 = call %jl_value_t* @julia_kron_70427(%UniformScaling* inttoptr (i64 4534667584 to %UniformScaling*), %jl_value_t* %46) #5
  %63 = load i64, i64* %17, align 8
  store i64 %63, i64* %14, align 8
  ret %jl_value_t* %62

if5:                                              ; preds = %L2
  %64 = getelementptr [17 x %jl_value_t*], [17 x %jl_value_t*]* %gcrootframe7, i64 0, i64 8
  store %jl_value_t* %36, %jl_value_t** %64, align 8
  %65 = call %jl_value_t* @julia_kron_70430(%jl_value_t* %36, %UniformScaling* inttoptr (i64 4534667584 to %UniformScaling*)) #5
  %66 = load i64, i64* %17, align 8
  store i64 %66, i64* %14, align 8
  ret %jl_value_t* %65
}

@dlfivefifty
Copy link
Contributor Author

The closest I've gotten to reducing the crash is to change dirichlet(d) to

Bx=dirichlet(d[1])
C=ConstantOperator{Float64,Float64}(1.0)
kron(Bx,C)

Running @code_llvm on the last line produces the following, which doesn't have a trap. I think I might try to work around it for ApproxFun now.

; Function Attrs: sspreq
define %jl_value_t* @julia_kron_70430(%jl_value_t*, %ConstantOperator*) #0 {
top:
  %2 = call %jl_value_t*** @jl_get_ptls_states() #2
  %gcrootframe1 = alloca [6 x %jl_value_t*], align 8
  %gcrootframe1.sub = getelementptr inbounds [6 x %jl_value_t*], [6 x %jl_value_t*]* %gcrootframe1, i64 0, i64 0
  %3 = getelementptr [6 x %jl_value_t*], [6 x %jl_value_t*]* %gcrootframe1, i64 0, i64 2
  %4 = getelementptr [6 x %jl_value_t*], [6 x %jl_value_t*]* %gcrootframe1, i64 0, i64 3
  %5 = getelementptr [6 x %jl_value_t*], [6 x %jl_value_t*]* %gcrootframe1, i64 0, i64 4
  %6 = getelementptr [6 x %jl_value_t*], [6 x %jl_value_t*]* %gcrootframe1, i64 0, i64 5
  %7 = bitcast [6 x %jl_value_t*]* %gcrootframe1 to i64*
  %8 = bitcast %jl_value_t** %3 to i8*
  call void @llvm.memset.p0i8.i64(i8* %8, i8 0, i64 32, i32 8, i1 false)
  store i64 8, i64* %7, align 8
  %9 = bitcast %jl_value_t*** %2 to i64*
  %10 = load i64, i64* %9, align 8
  %11 = getelementptr [6 x %jl_value_t*], [6 x %jl_value_t*]* %gcrootframe1, i64 0, i64 1
  %12 = bitcast %jl_value_t** %11 to i64*
  store i64 %10, i64* %12, align 8
  store %jl_value_t** %gcrootframe1.sub, %jl_value_t*** %2, align 8
  %13 = bitcast %ConstantOperator* %1 to i64*
  %14 = load i64, i64* %13, align 1
  %15 = bitcast %jl_value_t*** %2 to i8*
  %16 = getelementptr %jl_value_t**, %jl_value_t*** %2, i64 176
  %17 = bitcast %jl_value_t*** %16 to i8*
  %18 = call %jl_value_t* @jl_gc_pool_alloc(i8* %15, i8* %17, i32 32, i32 16328)
  %19 = getelementptr inbounds %jl_value_t, %jl_value_t* %18, i64 -1, i32 0
  store %jl_value_t* inttoptr (i64 4882167504 to %jl_value_t*), %jl_value_t** %19, align 8
  store %jl_value_t* %18, %jl_value_t** %3, align 8
  %20 = getelementptr inbounds %jl_value_t, %jl_value_t* %18, i64 1, i32 0
  %21 = bitcast %jl_value_t* %18 to i64*
  store i64 %14, i64* %21, align 16
  store %jl_value_t* %0, %jl_value_t** %20, align 8
  store %jl_value_t* %0, %jl_value_t** %4, align 8
  %22 = getelementptr inbounds %jl_value_t, %jl_value_t* %0, i64 3, i32 0
  %23 = bitcast %jl_value_t** %22 to i64*
  %24 = load i64, i64* %23, align 8
  %25 = getelementptr %jl_value_t**, %jl_value_t*** %2, i64 173
  %26 = bitcast %jl_value_t*** %25 to i8*
  %27 = call %jl_value_t* @jl_gc_pool_alloc(i8* %15, i8* %26, i32 16, i32 16360)
  %28 = getelementptr inbounds %jl_value_t, %jl_value_t* %27, i64 -1, i32 0
  store %jl_value_t* inttoptr (i64 4576175504 to %jl_value_t*), %jl_value_t** %28, align 8
  %29 = bitcast %jl_value_t* %27 to i64*
  store i64 %24, i64* %29, align 8
  store %jl_value_t* %27, %jl_value_t** %5, align 8
  %30 = call %jl_value_t* inttoptr (i64 4491105840 to %jl_value_t* (%jl_value_t*, %jl_value_t*)*)(%jl_value_t* inttoptr (i64 4882297040 to %jl_value_t*), %jl_value_t* %27)
  store %jl_value_t* %30, %jl_value_t** %6, align 8
  %31 = call %jl_value_t* @"julia_copy!_70431"(%jl_value_t* %30, %jl_value_t* %18) #1
  %32 = load i64, i64* %12, align 8
  store i64 %32, i64* %9, align 8
  ret %jl_value_t* %31
}

@vtjnash
Copy link
Member

vtjnash commented Jul 23, 2016

It appears to be in copy!. You can find out which exactly by calling print jl_(jl_gdblookuplinfo($pc)) from the right frame in gdb

@dlfivefifty
Copy link
Contributor Author

I don't know much about gdb (or lldb) so I'd need more instructions, in particular what "right frame" means. It would probably be better to do i tin lldb, since that seems to be giving more information.

@yuyichao
Copy link
Contributor

Run jameson's command when you see the sigill.

@dlfivefifty
Copy link
Contributor Author

I don’t think it worked out as intended:

[New Thread 0x1563 of process 23879]
[New Thread 0x1603 of process 23879]
[New Thread 0x1703 of process 23879]

Thread 1 received signal SIGILL, Illegal instruction.
0x000000030e768642 in ?? ()
(gdb) print jl_(jl_gdblookuplinfo($pc))
infrun.c:7476: internal-error: void insert_longjmp_resume_breakpoint(struct gdbarch *, CORE_ADDR): Assertion `inferior_thread ()->control.exception_resume_breakpoint == NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

On 24 Jul 2016, at 7:36 AM, Yichao Yu notifications@github.com wrote:

Run jameson's command when you see the sigill.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #17003 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ABLDqcNFL3gTZsuC64k2qMBq4gQzP3pNks5qYolhgaJpZM4I47aR.

@yuyichao
Copy link
Contributor

lldb

@dlfivefifty
Copy link
Contributor Author

Process 25112 stopped
* thread #1: tid = 0x4fc41, 0x000000030f968a72, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x000000030f968a72
->  0x30f968a72: ud2    
    0x30f968a74: nopw   %cs:(%rax,%rax)
    0x30f968a80: pushq  %rbp
    0x30f968a81: movq   %rsp, %rbp
(lldb) print jl_(jl_gdblookuplinfo($pc))
error: no matching function for call to 'jl_gdblookuplinfo'
note: candidate function not viable: no known conversion from 'unsigned long' to 'void *' for 1st argument; take the address of the argument with &
error: 1 errors parsing expression

@yuyichao
Copy link
Contributor

yuyichao commented Sep 3, 2016

A repro reduced from #18299 (it stack overflows instead of trap here but the reason is the same).

#!/usr/bin/julia

abstract C{T,N}

type A{T,N} <: C{T,N}
    v::T
end

typealias A1{T} C{T,1}

type B
    x::A
end

function f(x::A1)
end

function f(x::A)
    f(A(x))
end

function g(b::B)
    v = b.x
    f(v)
end

code_warntype(f, Tuple{A})
@code_warntype g(B(A{Int,1}(1)))

g(B(A{Int,1}(1)))

Somehow the type inference think only the wider type can match and therefore thinks it is always recursing and never returns. (Might be dup of one of the type intersection issues)

@yuyichao yuyichao added the compiler:inference Type inference label Sep 3, 2016
@yuyichao
Copy link
Contributor

yuyichao commented Sep 3, 2016

Actually the issue above is slightly different, there's a undetected ambiguity in the code above. The original code doesn't have the ambiguity so I still need to figure out the condition that triggers the original issue.

@yuyichao
Copy link
Contributor

yuyichao commented Sep 3, 2016

OK, this time by actually directly reducing the code from #18299 instead of trying to construct from bottom up half way through.....

abstract AArray{T,N}
typealias AVector{T} AArray{T,1}

immutable Nable{T}
end

immutable NArray{T,N} <: AArray{Nable{T},N}
end

(::Type{NArray}){T,N}(::Array{T,N}) = NArray{T,N}()

gl = [1, 2, 3]

f2(item::AVector) = nothing
f2(::Any) = f2(NArray(gl))

f2(1)

@vtjnash
Copy link
Member

vtjnash commented Sep 3, 2016

this is similar to #18307 then?

@yuyichao
Copy link
Contributor

yuyichao commented Sep 3, 2016

The ambiguity might be (the problem here seems that we always treat A <: B as more specific than B{T}). The original issue isn't.

@vtjnash vtjnash removed priority This should be addressed urgently regression Regression in behavior compared to a previous version labels Sep 15, 2016
@vtjnash
Copy link
Member

vtjnash commented Sep 15, 2016

probably will be fixed by #18457?

@StefanKarpinski StefanKarpinski added help wanted Indicates that a maintainer wants help on an issue or pull request and removed help wanted Indicates that a maintainer wants help on an issue or pull request labels Oct 27, 2016
@vtjnash vtjnash mentioned this issue Feb 27, 2017
53 tasks
@yuyichao yuyichao removed the help wanted Indicates that a maintainer wants help on an issue or pull request label Mar 1, 2017
@yuyichao
Copy link
Contributor

yuyichao commented Mar 1, 2017

Seems fixed.

@yuyichao yuyichao added the needs tests Unit tests are required for this change label Mar 1, 2017
@yuyichao yuyichao changed the title 0.5: Illegal instruction 4 segfault 0.5: Illegal instruction 4 Apr 7, 2017
KristofferC added a commit that referenced this issue May 26, 2017
@tkelman tkelman removed the needs tests Unit tests are required for this change label May 26, 2017
tkelman pushed a commit that referenced this issue Jun 3, 2017
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:inference Type inference
Projects
None yet
Development

No branches or pull requests

7 participants