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

stack can cause StackOverflowError or Segmentation fault on macOS ARM #121

Closed
gabrevaya opened this issue Sep 9, 2022 · 1 comment · Fixed by #125
Closed

stack can cause StackOverflowError or Segmentation fault on macOS ARM #121

gabrevaya opened this issue Sep 9, 2022 · 1 comment · Fixed by #125

Comments

@gabrevaya
Copy link
Contributor

Stacking vectors of length larger than 1353 causes a StackOverflowError:

julia> using MLUtils
for j in 1:2000
           a = [[1] for i in 1:j];
           stack(a, 2);
           @info j
end
.
.
.
[ Info: 1350
[ Info: 1351
[ Info: 1352
[ Info: 1353
ERROR: StackOverflowError:
Stacktrace:
 [1] __cat_offset!(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Tuple{Int64, Int64}, ::Matrix{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}}) (repeats 1339 times)
   @ Base ./abstractarray.jl:1749
 [2] __cat(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1744
 [3] _cat_t(::Int64, ::Type{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1737
 [4] _cat(::Int64, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ LinearAlgebra /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/LinearAlgebra/src/special.jl:424
 [5] cat(::Matrix{Int64}, ::Vararg{Matrix{Int64}}; dims::Int64)
   @ Base ./abstractarray.jl:1916
 [6] stack(xs::Vector{Vector{Int64}}; dims::Int64)
   @ MLUtils ~/.julia/packages/MLUtils/aThik/src/utils.jl:101
 [7] stack(x::Vector{Vector{Int64}}, dims::Int64)
   @ MLUtils ./deprecated.jl:72

However, if I restart the REPL I have this behaviour:

julia> using Pkg; Pkg.activate(".")
  Activating project at `~/Documents/doctorado/issues/MLUtils_stack`

julia> using MLUtils

julia> a = [[1] for i in 1:1354]; stack(a, 2);
ERROR: StackOverflowError:
Stacktrace:
 [1] __cat_offset!(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Tuple{Int64, Int64}, ::Matrix{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1746
 [2] __cat_offset!(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Tuple{Int64, Int64}, ::Matrix{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}}) (repeats 1339 times)
   @ Base ./abstractarray.jl:1749
 [3] __cat(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1744
 [4] _cat_t(::Int64, ::Type{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1737
 [5] _cat(::Int64, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ LinearAlgebra /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/LinearAlgebra/src/special.jl:424
 [6] cat(::Matrix{Int64}, ::Vararg{Matrix{Int64}}; dims::Int64)
   @ Base ./abstractarray.jl:1916
 [7] stack(xs::Vector{Vector{Int64}}; dims::Int64)
   @ MLUtils ~/.julia/packages/MLUtils/aThik/src/utils.jl:101
 [8] stack(x::Vector{Vector{Int64}}, dims::Int64)
   @ MLUtils ./deprecated.jl:72

julia> a = [[1] for i in 1:1353]; stack(a, 2);
ERROR: StackOverflowError:
Stacktrace:
 [1] __cat_offset!(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Tuple{Int64, Int64}, ::Matrix{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}}) (repeats 1352 times)
   @ Base ./abstractarray.jl:1749
 [2] __cat(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1744
 [3] _cat_t(::Int64, ::Type{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1737
 [4] _cat(::Int64, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ LinearAlgebra /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/LinearAlgebra/src/special.jl:424
 [5] cat(::Matrix{Int64}, ::Vararg{Matrix{Int64}}; dims::Int64)
   @ Base ./abstractarray.jl:1916
 [6] stack(xs::Vector{Vector{Int64}}; dims::Int64)
   @ MLUtils ~/.julia/packages/MLUtils/aThik/src/utils.jl:101
 [7] stack(x::Vector{Vector{Int64}}, dims::Int64)
   @ MLUtils ./deprecated.jl:72

julia> a = [[1] for i in 1:1352]; stack(a, 2);
ERROR: StackOverflowError:

julia> a = [[1] for i in 1:1351]; stack(a, 2);

signal (11): Segmentation fault: 11
in expression starting at REPL[8]:1
_ZN4llvm16InstCombinerImpl15visitSelectInstERNS_10SelectInstE at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libLLVM.dylib (unknown line)
Allocations: 3717522 (Pool: 3708463; Big: 9059); GC: 5

And Julia exits.

(MLUtils_stack) pkg> st
Status `~/Documents/doctorado/issues/MLUtils_stack/Project.toml`
  [f1d291b0] MLUtils v0.2.10
julia> versioninfo()
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 8 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 6 virtual cores
@CarloLucibello
Copy link
Member

This is the same as FluxML/Flux.jl#1585

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants