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

Bound violation in SparseArrays - segfault #31024

Closed
KlausC opened this issue Feb 9, 2019 · 2 comments · Fixed by #31724
Closed

Bound violation in SparseArrays - segfault #31024

KlausC opened this issue Feb 9, 2019 · 2 comments · Fixed by #31724
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays

Comments

@KlausC
Copy link
Contributor

KlausC commented Feb 9, 2019

As reported here: slack.
The code below produces a segfault.

When starting julia --check-bounds=yes the following stack trace is produced:

v"1.2.0-DEV.337"
v"1.0.3"

julia> using SparseArrays
julia> I1 = [Int8(i) for i in 1:20 for _ in 1:20];
julia> J = [Int8(i) for _ in 1:20 for i in 1:20];
julia> V = fill(1, length(I1));

julia> sparse(I1, J, V)
ERROR: BoundsError: attempt to access 400-element Array{Int8,1} at index [-128]
Stacktrace:
 [1] setindex! at ./array.jl:766 [inlined]
 [2] setindex! at ./multidimensional.jl:460 [inlined]
 [3] sparse!(::Array{Int8,1}, ::Array{Int8,1}, ::Array{Int64,1}, ::Int64, ::Int64, ::typeof(+), ::Array{Int8,1}, ::Array{Int8,1}, ::Array{Int8,1}, ::Array{Int64,1}, ::Array{Int8,1}, ::Array{Int8,1}, ::Array{Int64,1}) at /home/julia/julia/usr/share/julia/stdlib/v1.2/SparseArrays/src/sparsematrix.jl:696
 [4] sparse(::Array{Int8,1}, ::Array{Int8,1}, ::Array{Int64,1}, ::Int64, ::Int64, ::Function) at /home/julia/julia/usr/share/julia/stdlib/v1.2/SparseArrays/src/sparsematrix.jl:604
 [5] sparse at /home/julia/julia/usr/share/julia/stdlib/v1.2/SparseArrays/src/sparsematrix.jl:788 [inlined]
 [6] sparse(::Array{Int8,1}, ::Array{Int8,1}, ::Array{Int64,1}) at /home/julia/julia/usr/share/julia/stdlib/v1.2/SparseArrays/src/sparsematrix.jl:784
 [7] top-level scope at REPL[8]:1
@KlausC
Copy link
Contributor Author

KlausC commented Feb 9, 2019

I think, the type for Ti = Int8 is not wide enough. That should be handled by sparse, though.

@KristofferC
Copy link
Member

PR got reverted in #31667

@KristofferC KristofferC reopened this Apr 10, 2019
ViralBShah pushed a commit that referenced this issue Jun 26, 2019
* reconstruct PR #31118

* reconstruct PR 31118 2

* Check arguments of SparseMatrixCSC #31024 #31435

* fix SuiteSparse test

* added NEWS, fixed tests

* loosen restrictions - resize to useful length

* cleaned up NEWS, revert minor change

* add non-checking and checking constructor - improve check performance
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 sparse Sparse arrays
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants