Skip to content

Commit 9e63d0c

Browse files
Guard DDE full_cache resize against already-resized aliased arrays
The DDE resize! function first resizes ode_integrator.u and ode_integrator.k elements, then iterates full_cache(cache) to resize all cache arrays. Some cache arrays are aliased to the already-resized arrays (e.g., cache.u === ode_integrator.u, cache.fsalfirst === integrator.k[1]). On Julia 1.10 x86, calling resize! on an already-resized array that shares data triggers "cannot resize array with shared data". Add a length guard to skip arrays already at the target length. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent f41d8ec commit 9e63d0c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/integrators/interface.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,14 @@ function Base.resize!(integrator::DDEIntegrator, cache, i)
227227
end
228228

229229
# resize DDE integrator
230+
# Skip arrays already at the target length to avoid redundant resize!
231+
# calls on aliased arrays (e.g., cache.u === ode_integrator.u,
232+
# cache.fsalfirst === integrator.k[1]), which can fail with
233+
# "cannot resize array with shared data" on some platforms.
230234
for c in full_cache(cache)
231-
resize!(c, i)
235+
length(c) != i && resize!(c, i)
232236
end
237+
233238
OrdinaryDiffEqCore.resize_nlsolver!(integrator, i)
234239
OrdinaryDiffEqCore.resize_J_W!(cache, integrator, i)
235240
resize_non_user_cache!(integrator, cache, i)

0 commit comments

Comments
 (0)