-
Notifications
You must be signed in to change notification settings - Fork 149
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
Unnecessary allocations and illegal instruction crash with broadcasting #482
Comments
Same story on current master, for completeness: | | |_| | | | (_| | | Version 1.1.0-DEV.144 (2018-08-30)
_/ |\__'_|_|_|\__'_| | Commit dabf70e6fe (0 days old master)
|__/ |
julia> versioninfo()
Julia Version 1.1.0-DEV.144
Commit dabf70e6fe (2018-08-30 18:40 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: AMD Ryzen 7 1800X Eight-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, znver1)
(v1.1) pkg> st
Status `~/.julia/environments/v1.1/Project.toml`
[6e4b80f9] BenchmarkTools v0.4.0
[90137ffa] StaticArrays v0.8.3
julia> using LinearAlgebra
julia> using StaticArrays
julia> using BenchmarkTools
julia> perp(v) = SVector(v[2], -v[1])
perp (generic function with 1 method)
julia> X = rand(SVector{10,SVector{2,Float64}})
10-element SArray{Tuple{10},SArray{Tuple{2},Float64,1,2},1,10}:
[0.392512, 0.794166]
[0.763505, 0.157252]
[0.521086, 0.562327]
[0.308199, 0.858053]
[0.989704, 0.231244]
[0.110478, 0.675843]
[0.427602, 0.428346]
[0.767848, 0.184462]
[0.369643, 0.998114]
[0.487112, 0.660135]
julia> f(X) = perp.(X) ./ norm.(X)
f (generic function with 1 method)
julia> @benchmark f($X)
BenchmarkTools.Trial:
memory estimate: 1.17 KiB
allocs estimate: 4
--------------
minimum time: 109.667 ns (0.00% GC)
median time: 134.751 ns (0.00% GC)
mean time: 156.357 ns (12.65% GC)
maximum time: 30.816 μs (99.26% GC)
--------------
samples: 10000
evals/sample: 943
julia> @benchmark f($X)
Unreachable reached at 0x7f96cd03059a
signal (4): Illegal instruction
in expression starting at no file:0
copy at /home/schmrlng/.julia/packages/StaticArrays/Ze5H3/src/broadcast.jl:24 [inlined]
materialize at ./broadcast.jl:748 [inlined]
f at ./REPL[8]:1 [inlined]
##core#366 at /home/schmrlng/.julia/packages/BenchmarkTools/vesay/src/execution.jl:293
##sample#367 at /home/schmrlng/.julia/packages/BenchmarkTools/vesay/src/execution.jl:299
#_run#4 at /home/schmrlng/.julia/packages/BenchmarkTools/vesay/src/execution.jl:327
unknown function (ip: 0x7f96cd03035b)
jl_fptr_trampoline at /home/schmrlng/code/oss/julia-master/src/gf.c:1841
jl_apply_generic at /home/schmrlng/code/oss/julia-master/src/gf.c:2196
inner at ./none:0
jl_fptr_trampoline at /home/schmrlng/code/oss/julia-master/src/gf.c:1841
jl_apply_generic at /home/schmrlng/code/oss/julia-master/src/gf.c:2196
jl_apply at /home/schmrlng/code/oss/julia-master/src/julia.h:1558 [inlined]
jl_f__apply at /home/schmrlng/code/oss/julia-master/src/builtins.c:556
jl_f__apply_latest at /home/schmrlng/code/oss/julia-master/src/builtins.c:594
#invokelatest#1 at ./essentials.jl:690 [inlined]
#invokelatest at ./none:0 [inlined]
#run_result#16 at /home/schmrlng/.julia/packages/BenchmarkTools/vesay/src/execution.jl:32 [inlined]
#run_result at ./none:0 [inlined]
#run#18 at /home/schmrlng/.julia/packages/BenchmarkTools/vesay/src/execution.jl:46
jl_fptr_trampoline at /home/schmrlng/code/oss/julia-master/src/gf.c:1841
jl_apply_generic at /home/schmrlng/code/oss/julia-master/src/gf.c:2196
warmup at ./none:0
jl_fptr_trampoline at /home/schmrlng/code/oss/julia-master/src/gf.c:1841
jl_apply_generic at /home/schmrlng/code/oss/julia-master/src/gf.c:2196
do_call at /home/schmrlng/code/oss/julia-master/src/interpreter.c:324
eval_value at /home/schmrlng/code/oss/julia-master/src/interpreter.c:430
eval_stmt_value at /home/schmrlng/code/oss/julia-master/src/interpreter.c:363 [inlined]
eval_body at /home/schmrlng/code/oss/julia-master/src/interpreter.c:688
jl_interpret_toplevel_thunk_callback at /home/schmrlng/code/oss/julia-master/src/interpreter.c:803
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f96b8e342df)
unknown function (ip: 0x9)
jl_interpret_toplevel_thunk at /home/schmrlng/code/oss/julia-master/src/interpreter.c:812
jl_toplevel_eval_flex at /home/schmrlng/code/oss/julia-master/src/toplevel.c:792
jl_toplevel_eval_in at /home/schmrlng/code/oss/julia-master/src/builtins.c:622
eval at ./boot.jl:319
jl_apply_generic at /home/schmrlng/code/oss/julia-master/src/gf.c:2196
eval_user_input at /home/schmrlng/code/oss/julia-master/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85
macro expansion at /home/schmrlng/code/oss/julia-master/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:259
jl_apply_generic at /home/schmrlng/code/oss/julia-master/src/gf.c:2196
jl_apply at /home/schmrlng/code/oss/julia-master/src/julia.h:1558 [inlined]
start_task at /home/schmrlng/code/oss/julia-master/src/task.c:271
unknown function (ip: 0xffffffffffffffff)
Allocations: 55894048 (Pool: 55890429; Big: 3619); GC: 560
[1] 29696 illegal hardware instruction (core dumped) ./julia |
Without needing # test.jl
using LinearAlgebra
using StaticArrays
import StaticArrays: SUnitRange
perp(v) = SVector(v[2], -v[1])
struct A{N,T}
v::SVector{N,SVector{2,T}}
function A{N,T}(X) where {N,T}
new(normalize.(perp.(X)))
end
end
A(X) = A{length(X),eltype(eltype(X))}(X)
X = rand(SVector{3,SVector{2,Float64}})
@show typeof(X)
@show typeof(perp.(X))
@show typeof(normalize.(perp.(X)))
A(X) resulting in
|
This seems fixed now, OK to close? |
The segfault seems to be fixed but I would still think that |
This is probably a base julia bug, but maybe we're doing something improper with broadcasting? The crash below happens consistently for me on the second
@benchmark
run.The text was updated successfully, but these errors were encountered: