# Crash on access of EnsembleSolution

**URL:** https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620
**Category:** General Usage
**Tags:** diffeq, bug
**Created:** [October 19, 2020, 11:17am UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620 "2020-10-19T11:17:55Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![peatlux](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@peatlux](https://discourse.julialang.org/u/peatlux)
#### Post date: [October 19, 2020, 11:17am UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/1 "2020-10-19T11:17:55Z")

</div>

Hello,  
I’ve experienced a crash of julia when I wanted to access my EnsembleSolution. The message told me to report the bug. Since I don’t know where to report it, I do it here. Below is my code to produce the EnsembleSolution:

```julia
using Plots, DifferentialEquations, LaTeXStrings;
c=1500.0       
kappa=4/3    
P_stat=100.0e+3  
P_v=2.33e+3     
rho=998.0      
sigma=0.0725  
mu= 0.001
P_s=80e+3        
R_n=10e-6       
v=70e+3    
function bubbleKME2(dx,x,p,t) 
    dx[1]=x[2]
    dx[3]=v
    dx[2]=(-x[2]^2/2*(3-x[2]/c) +(1+(1-3*kappa)*x[2]/c)*((P_stat-P_v)/rho+2*sigma/(rho*p[1]))*(p[1]/x[1])^(3*kappa)
            -2*sigma/(rho*x[1]) -4*mu*x[2]/(rho*x[1]) -(1+x[2]/c)*(P_stat-P_v+P_s*sin(2*pi*x[3]))/rho
            -x[1]*2*pi*v*P_s/(rho*c)*cos(2*pi*x[3])
           )/((1-x[2]/c)*x[1]+4*mu/(rho*c))
end
U0=0.0
Theta0=0.0
R_n=10e-6
x0=[R_n,U0,Theta0]
tspan=(0.0,0.0015)
p=[R_n]
prob=ODEProblem(bubbleKME2, x0, tspan,p)
function prob_func(prob,i,repeat)
    x=prob.p[1] +i*3e-8
  remake(prob,u0=-[1e-7,0.,0.]+[x,0.,0.],p=[x])
end
ensemble_prob = EnsembleProblem(prob,prob_func=prob_func)
sim = solve(ensemble_prob,Tsit5(),trajectories=85, progress=true)

```

I know this lowly optimized, but anyways I get a crash when I want to access `sim[1,:,3]` (value 1 at all times of my 3rd solution). Or any other solution except the first one.

The error messages are:

```julia
Exception: EXCEPTION_ACCESS_VIOLATION at 0x3d8d1ced -- getindex at .\array.jl:809 [inlined]
getindex at C:\Users\vluxm\.julia\packages\RecursiveArrayTools\a2bjs\src\vector_of_array.jl:66 [inlined]
getindex at C:\Users\vluxm\.julia\packages\RecursiveArrayTools\a2bjs\src\vector_of_array.jl:66 [inlined]
macro expansion at .\multidimensional.jl:772 [inlined]
macro expansion at .\cartesian.jl:64 [inlined]
macro expansion at .\multidimensional.jl:767 [inlined]
_unsafe_getindex! at .\multidimensional.jl:762 [inlined]
_unsafe_getindex at .\multidimensional.jl:757
in expression starting at none:1
getindex at .\array.jl:809 [inlined]
getindex at C:\Users\vluxm\.julia\packages\RecursiveArrayTools\a2bjs\src\vector_of_array.jl:66 [inlined]
getindex at C:\Users\vluxm\.julia\packages\RecursiveArrayTools\a2bjs\src\vector_of_array.jl:66 [inlined]
macro expansion at .\multidimensional.jl:772 [inlined]
macro expansion at .\cartesian.jl:64 [inlined]
macro expansion at .\multidimensional.jl:767 [inlined]
_unsafe_getindex! at .\multidimensional.jl:762 [inlined]
_unsafe_getindex at .\multidimensional.jl:757
_getindex at .\multidimensional.jl:743 [inlined]
getindex at .\abstractarray.jl:1060
unknown function (ip: 000000003D8D2382)
jl_apply at /cygdrive/d/buildbot/worker/package_win64/build/src\julia.h:1690 [inlined]
do_call at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:117
eval_value at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:206
eval_stmt_value at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:157 [inlined]
eval_body at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:548
jl_interpret_toplevel_thunk at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:660
jl_toplevel_eval_flex at /cygdrive/d/buildbot/worker/package_win64/build/src\toplevel.c:840
jl_toplevel_eval at /cygdrive/d/buildbot/worker/package_win64/build/src\toplevel.c:849 [inlined]
jl_toplevel_eval_in at /cygdrive/d/buildbot/worker/package_win64/build/src\toplevel.c:883
eval at .\boot.jl:331 [inlined]
repleval at C:\Users\vluxm\.julia\packages\Atom\9OFfu\src\repl.jl:196
#242 at C:\Users\vluxm\.julia\packages\Atom\9OFfu\src\repl.jl:226
unknown function (ip: 000000003D8CEDC3)
with_logstate at .\logging.jl:408
with_logger at .\logging.jl:514 [inlined]
evalrepl at C:\Users\vluxm\.julia\packages\Atom\9OFfu\src\repl.jl:214
jl_apply at /cygdrive/d/buildbot/worker/package_win64/build/src\julia.h:1690 [inlined]
do_call at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:117
eval_value at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:206
eval_stmt_value at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:157 [inlined]
eval_body at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:548
jl_interpret_toplevel_thunk at /cygdrive/d/buildbot/worker/package_win64/build/src\interpreter.c:660
jl_toplevel_eval_flex at /cygdrive/d/buildbot/worker/package_win64/build/src\toplevel.c:840
jl_toplevel_eval at /cygdrive/d/buildbot/worker/package_win64/build/src\toplevel.c:849 [inlined]
jl_toplevel_eval_in at /cygdrive/d/buildbot/worker/package_win64/build/src\toplevel.c:883
eval at .\boot.jl:331
eval_user_input at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\REPL\src\REPL.jl:134
repl_backend_loop at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\REPL\src\REPL.jl:195
start_repl_backend at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\REPL\src\REPL.jl:180
#run_repl#37 at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\REPL\src\REPL.jl:292
run_repl at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\REPL\src\REPL.jl:288
#806 at .\client.jl:399
jfptr_YY.806_58616.clone_1 at C:\Users\vluxm\AppData\Local\Programs\Julia 1.5.0\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/d/buildbot/worker/package_win64/build/src\julia.h:1690 [inlined]
do_apply at /cygdrive/d/buildbot/worker/package_win64/build/src\builtins.c:655
jl_f__apply at /cygdrive/d/buildbot/worker/package_win64/build/src\builtins.c:669 [inlined]
jl_f__apply_latest at /cygdrive/d/buildbot/worker/package_win64/build/src\builtins.c:705
#invokelatest#1 at .\essentials.jl:710 [inlined]
invokelatest at .\essentials.jl:709 [inlined]
run_main_repl at .\client.jl:383
exec_options at .\client.jl:313
_start at .\client.jl:506
jfptr__start_54312.clone_1 at C:\Users\vluxm\AppData\Local\Programs\Julia 1.5.0\lib\julia\sys.dll (unknown line)
unknown function (ip: 00000000004017E1)
unknown function (ip: 0000000000401BD6)
unknown function (ip: 00000000004013DE)
unknown function (ip: 000000000040151A)
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 423111050 (Pool: 423030544; Big: 80506); GC: 179

```

I am working with:

```julia
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-7440HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = "C:\Users\vluxm\AppData\Local\atom\app-1.48.0\atom.exe" -a
  JULIA_NUM_THREADS = 2

```

I’ve seen there is a new bug report system with rr trace. But I dont know how to do it with Windows.  
Thanks and Greetings

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [October 19, 2020, 11:27am UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/2 "2020-10-19T11:27:24Z")

</div>

First, you should check if it still crashes with the current nightly build, which you can get here:

> **[Julia Downloads (nightly binaries)](https://julialang.org/downloads/nightlies/)**
>
> The official website for the Julia Language. Julia is a language that is fast, dynamic, easy to use, and open source. Click here to learn more.

Then the place to report this is here:

> **[Issues · JuliaLang/julia](https://github.com/JuliaLang/julia/issues)**
>
> The Julia Programming Language. Contribute to JuliaLang/julia development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![peatlux](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@peatlux](https://discourse.julialang.org/u/peatlux)
#### Post date: [October 19, 2020, 11:53am UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/3 "2020-10-19T11:53:15Z")

</div>

In the nightly build:

> You can expect many packages not to work with this version.

I need the packages for my further work. Can I install the dev version with my current build remaining untouched?

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [October 19, 2020, 11:56am UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/4 "2020-10-19T11:56:29Z")

</div>

Yes, you can.

---

<div class="post-metadata">

### Author: ![peatlux](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@peatlux](https://discourse.julialang.org/u/peatlux)
#### Post date: [October 19, 2020, 12:21pm UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/5 "2020-10-19T12:21:52Z")

</div>

Ok. I did it. Now it doesn’t crash anymore. But there comes an error.  
I’ve figured out that this error only occurs when the specific solution has a different length.  
So in my case I can access only solutions with exactly 3957 elements. Any other solution with a different length leads to an error with `sim[1,:,#ofSolution]`.

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [October 19, 2020, 12:24pm UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/6 "2020-10-19T12:24:37Z")

</div>

Hmm, now it is quite specific. I let it to the experts.

---

<div class="post-metadata">

### Author: ![peatlux](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@peatlux](https://discourse.julialang.org/u/peatlux)
#### Post date: [October 19, 2020, 12:44pm UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/7 "2020-10-19T12:44:11Z")

</div>

I guess there’s an issue with the `:` - macro.  
It works when I use `sim[#ofSolution][1,:]` instead of `sim[1,:,#ofSolution]`.

---

<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: [October 19, 2020, 1:01pm UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/8 "2020-10-19T13:01:05Z")

</div>

```julia
julia> size(sim)
(3, 3957, 85)

julia> size(sim[1].u)
(3957,)

```

The simulation is treated as being 3 x 3957 x 85.  
This is despite the fact that for the second simulation, we have 3978 time points, more than 3957:

```julia
julia> size(sim[2].u)
(3978,)

```

Therefore, if we take a slice of the second time point, we only get the first 3957 time points back, not all 3978

```julia
julia> size(sim[1,:,2])
(3957,)

julia> u2_v1 = first.(sim[2].u);

julia> u2_v2 = sim[1,:,2];

julia> u2_v1[eachindex(u2_v2)] == u2_v2
true

julia> length.((u2_v1, u2_v2))
(3978, 3957)

```

Meanwhile, the third solution:

```julia
julia> size(sim[3].u)
(3928,)

```

Has 3928 time points, less than 3957. Hence the segfault.

EDIT:  
Beaten to it by 40 minutes: [Crash on access of EnsembleSolution - #5 by peatlux](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/5)  
As a workaround, I’d do `getindex.(sim[j].u, i)` instead of `sim[i,:,j]`.

---

<div class="post-metadata">

### Author: ![peatlux](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@peatlux](https://discourse.julialang.org/u/peatlux)
#### Post date: [October 19, 2020, 1:09pm UTC](https://discourse.julialang.org/t/crash-on-access-of-ensemblesolution/48620/9 "2020-10-19T13:09:09Z")

</div>

Thanks a lot! This was really very fast help.  
So the `:`-macro works as intended?  
If yes, shall I delete the issue on github?
