# StackOverflowError related to \`SizedMatrix\`

**URL:** <https://discourse.julialang.org/t/stackoverflowerror-related-to-sizedmatrix/98647>\
**Category:** General Usage\
**Created:** [May 10, 2023, 9:39pm UTC](https://discourse.julialang.org/t/stackoverflowerror-related-to-sizedmatrix/98647 "2023-05-10T21:39:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 10, 2023, 9:39pm UTC](https://discourse.julialang.org/t/stackoverflowerror-related-to-sizedmatrix/98647/1 "2023-05-10T21:39:49Z")

</div>

I have a complex code and received a `StackOverflowError` associated with `StaticArrays’. More precisely, I received the message:

```julia
ERROR: StackOverflowError:
Stacktrace:
 [1] SizedMatrix{3, 3, Float32, 2, Matrix{Float32}}(a::Matrix{Float64}) (repeats 2 times)
   @ StaticArrays ~/.julia/packages/StaticArrays/VLqRb/src/SizedArray.jl:15

```

What is bothersome is that the stack trace is so short. Whatever the error, why is there not more information provided. In so many other instances, the stacktrace is enormous!

What is even more surprising is that the error relates to [`SizedMatrix`](https://juliaarrays.github.io/StaticArrays.jl/stable/pages/api/#SizedArray:-a-decorate-size-wrapper-for-Array), which according to the documentation, is allocated on the heap:

`Another convenient mutable type is the SizedArray, which is just a wrapper-type about a standard Julia Array which declares its known size. For example, if we knew that a was a 2×2 Matrix, then we can type sa = SizedArray{Tuple{2,2}}(a) to construct a new object which knows the type (the size will be verified automatically). For one and two dimensions, a more convenient syntax for obtaining a SizedArray is by using the SizedMatrix and SizedVector aliases, e.g. sa = SizedMatrix{2,2}(a). `

I know what routine the error occurred in, although I do not know why. The code worked earlier this afternoon, so I made some change that had repercussions. My question is why the stack trace is not complete. Thanks.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 10, 2023, 10:09pm UTC](https://discourse.julialang.org/t/stackoverflowerror-related-to-sizedmatrix/98647/2 "2023-05-10T22:09:39Z")

</div>

I fixed my error (for now). I noticed in the code:

```julia
σ0 = SizedMatrix{3,3}([0f0 0f0 0f0; 0f0 0f0 0f0; 0f0 0f0 0f0])

```

which indicates that a template is defined as `Float64` has elements that are `Float32`. The code worked a while ago, but conceivably the results were wrong. I still don’t understand how a stacktrace error could have occurred.
