Closed
Description
Checked with current master 36d0116:
julia> versioninfo()
Julia Version 1.1.0-DEV.705
Commit 36d0116 (2018-11-21 20:37 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)
julia> using SparseArrays
julia> ((_, x) -> x).(Int, spzeros(3))
3-element SparseVector{Float64,Int64} with 0 stored entries
julia> ((_, _, x) -> x).(Int, Int, spzeros(3))
Unreachable reached at 0x7fc3987e0990
signal (4): Illegal instruction
in expression starting at no file:0
copy at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:965 [inlined]
materialize at ./broadcast.jl:756
jl_fptr_trampoline at /home/takafumi/repos/watch/julia/src/gf.c:1854
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2209
do_call at /home/takafumi/repos/watch/julia/src/interpreter.c:323
eval_value at /home/takafumi/repos/watch/julia/src/interpreter.c:411
eval_stmt_value at /home/takafumi/repos/watch/julia/src/interpreter.c:362 [inlined]
eval_body at /home/takafumi/repos/watch/julia/src/interpreter.c:759
jl_interpret_toplevel_thunk_callback at /home/takafumi/repos/watch/julia/src/interpreter.c:885
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fc3a96b154f)
unknown function (ip: 0x8)
jl_interpret_toplevel_thunk at /home/takafumi/repos/watch/julia/src/interpreter.c:894
jl_toplevel_eval_flex at /home/takafumi/repos/watch/julia/src/toplevel.c:764
jl_toplevel_eval_in at /home/takafumi/repos/watch/julia/src/toplevel.c:793
eval at ./boot.jl:319
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2209
eval_user_input at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85
macro expansion at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117 [inlined]
#26 at ./task.jl:259
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2209
jl_apply at /home/takafumi/repos/watch/julia/src/julia.h:1571 [inlined]
start_task at /home/takafumi/repos/watch/julia/src/task.c:572
unknown function (ip: 0xffffffffffffffff)
Allocations: 10894497 (Pool: 10891786; Big: 2711); GC: 23
zsh: illegal hardware instruction ./julia --startup-file=no
[Update: #30120 fixes the following]
Note that it is likely that ((_, _, x) -> x).(Int, Int, spzeros(3))
cannot be called due to method ambiguity (even if illegal instruction is fixed):
julia> ((_, _, _, x) -> x).(Int, Int, Int, zeros(3)) # works with normal array
3-element Array{Float64,1}:
0.0
0.0
0.0
julia> ((_, _, _, x) -> x).(Int, Int, Int, spzeros(3))
ERROR: MethodError: SparseArrays.HigherOrderFns.capturescalars(::getfield(SparseArrays.HigherOrderFns, Symbol("##5#6")){Int64,getfield(Main, Symbol("##5#6"))}, ::Tuple{Base.RefValue{Type{Int64}},Base.RefValue{Type{Int64}},SparseVector{Float64,Int64}}) is ambiguous. Candidates:
capturescalars(f, mixedargs::Tuple{Union{AbstractArray{0,N} where N, Ref},Ref{Type{T}},Vararg{Any,N} where N}) where T in SparseArrays.HigherOrderFns at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:1029
capturescalars(f, mixedargs::Tuple{Ref{Type{T}},Vararg{Any,N} where N}) where T in SparseArrays.HigherOrderFns at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:1025
Possible fix, define
capturescalars(::Any, ::Tuple{Ref{Type{T}},Ref{Type{T}},Vararg{Any,N} where N})
Stacktrace:
[1] capturescalars at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:1025 [inlined]
[2] _copy(::Function, ::Base.RefValue{Type{Int64}}, ::Vararg{Any,N} where N) at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:973
[3] copy at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:965 [inlined]
[4] materialize(::Base.Broadcast.Broadcasted{SparseArrays.HigherOrderFns.SparseVecStyle,Nothing,getfield(Main, Symbol("##5#6")),Tuple{Base.RefValue{Type{Int64}},Base.RefValue{Type{Int64}},Base.RefValue{Type{Int64}},SparseVector{Float64,Int64}}}) at ./broadcast.jl:756
[5] top-level scope at none:0