# Rand! + MvNormal = StackOverflowError

**URL:** <https://discourse.julialang.org/t/rand-mvnormal-stackoverflowerror/73462>\
**Category:** General Usage\
**Created:** [December 21, 2021, 11:45pm UTC](https://discourse.julialang.org/t/rand-mvnormal-stackoverflowerror/73462 "2021-12-21T23:45:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PharmCat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pharmcat/32/6953_2.png) [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Post date:** [December 21, 2021, 11:45pm UTC](https://discourse.julialang.org/t/rand-mvnormal-stackoverflowerror/73462/1 "2021-12-21T23:45:23Z")

</div>

Hello!  
Is it expected behavior with `rand!(zeros(4), MvNormal(Diagonal([1,2,3,4])))`?

```julia
Starting Julia...
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.    
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.7.0 (2021-11-30)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release  
|__/ |

julia> using Random; using Distributions; using LinearAlgebra; rand!(zeros(4), MvNormal(Diagonal([1,2,3,4])))
ERROR: StackOverflowError:
Stacktrace:
 [1] rand!(rng::TaskLocalRNG, A::Vector{Float64}, X::MvNormal{Int64, PDMats.PDiagMat{Int64, Vector{Int64}}, FillArrays.Zeros{Int64, 1, Tuple{Base.OneTo{Int64}}}}) (repeats 79984 times)
   @ Random C:\Users\...\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Random\src\Random.jl:267

julia> 

```
