# Crash on access of EnsembleSolution

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:

``````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:

``````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)
Allocations: 423111050 (Pool: 423030544; Big: 80506); GC: 179
``````

I am working with:

``````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

``````

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

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

Then the place to report this is here:

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?

Yes, you can.

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]`.

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

1 Like

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

``````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> 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> 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> 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
As a workaround, I’d do `getindex.(sim[j].u, i)` instead of `sim[i,:,j]`.

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