# @turbo Segfault with empty rows in SparseMatrix

**URL:** <https://discourse.julialang.org/t/turbo-segfault-with-empty-rows-in-sparsematrix/102821>\
**Category:** General Usage\
**Created:** [August 15, 2023, 9:21am UTC](https://discourse.julialang.org/t/turbo-segfault-with-empty-rows-in-sparsematrix/102821 "2023-08-15T09:21:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f.ij](https://avatars.discourse-cdn.com/v4/letter/f/8491ac/32.png) [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Post date:** [August 15, 2023, 9:21am UTC](https://discourse.julialang.org/t/turbo-segfault-with-empty-rows-in-sparsematrix/102821/1 "2023-08-15T09:21:20Z")

</div>

I’m trying to use the `@turbo` macro from LoopVectorization iterating over values from a sparse array. The way I’m doing it is the following:

I have a variable `state::Vector{Float32}` and a square sparse matrix holding `Float32` values, with both dimensions equal to the length `state`. Then I pick a random index in a loop and evaluate the following function:

```julia
function getEFactor(state, sparse::SparseMatrixCSC, idx)
    efac = 0f0 
    @turbo for idx in nzrange(sparse, idx)
        efac += -state[sparse.rowval[idx]] * sparse.nzval[idx]
    end
    return efac
end

```

It seems to SIMD correctly, but I get segfaults when idx corresponds to an empty row of the matrix.

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [August 15, 2023, 1:17pm UTC](https://discourse.julialang.org/t/turbo-segfault-with-empty-rows-in-sparsematrix/102821/2 "2023-08-15T13:17:03Z")

</div>

`@turbo check_empty=true`
