StackOverflow when passing dictionary to ODE solver?

Hi, I’m getting a stackoverflow error (full error message below) when I try to pass my parameters as a dictionary. Simple example:

using DifferentialEquations
using Plots
using StatsKit

function lorenz!(du, u, p, t)
    p1 = p["p1"]
    p2 = p["p2"]
    p3 = p["p3"]

    du[1] = p1 * (u[2] - u[1])
    du[2] = u[1] * (p2 - u[3]) - u[2]
    du[3] = u[1] * u[2] - p3 * u[3]
end

pd = Dict("p1" => 10.0, "p2" => 28.0, "p3" => 8/3)
u0 = [1.0, 1.0, 1.0] # Initial conditions
tspan = (0.0, 10.0) # Time span for the solution

# Check no error is thrown if I just call the ode function as is:
lorenz!([0.0,0.0,0.0], u0, pd, 0.0)

# Dictionary, this has been failing
probd = ODEProblem(lorenz!, u0, tspan, pd)
sold = DataFrame(solve(probd, QNDF(), saveat=0.1)) # Long error
plot!(sold.value1,sold.value2)

If I convert pd to a DataFrame or a NamedTuple (adding additional methods for lorenz!) this works as expected. I feel like this used to work fine?

Here is the error message:

ERROR: StackOverflowError:
Stacktrace:
     [1] GenericMemory
       @ .\boot.jl:516 [inlined]
     [2] rehash!(h::Dict{String, Float64}, newsz::Int64)
       @ Base .\dict.jl:147
     [3] #sizehint!#423
       @ .\dict.jl:199 [inlined]
     [4] sizehint!
       @ .\dict.jl:193 [inlined]
     [5] Dict{String, Float64}(kv::Vector{Pair{String, Float64}})
       @ Base .\dict.jl:92
     [6] dict_with_eltype
       @ .\abstractdict.jl:635 [inlined]
     [7] Dict
       @ .\dict.jl:117 [inlined]
     [8] remake_buffer(sys::ODEProblem{…}, oldbuffer::Dict{…}, idxs::Base.KeySet{…}, vals::Base.ValueIterator{…})
       @ SymbolicIndexingInterface C:\Users\rieget\.julia\packages\SymbolicIndexingInterface\3UAF0\src\remake.jl:61
     [9] remake_buffer(sys::ODEProblem{…}, oldbuffer::Dict{…}, vals::Dict{…})
       @ SymbolicIndexingInterface .\deprecated.jl:105
--- the above 2 lines are repeated 9291 more times ---
 [18592] remake_buffer(sys::ODEProblem{…}, oldbuffer::Dict{…}, idxs::Base.KeySet{…}, vals::Base.ValueIterator{…})
       @ SymbolicIndexingInterface C:\Users\rieget\.julia\packages\SymbolicIndexingInterface\3UAF0\src\remake.jl:61
 [18593] _updated_u0_p_symmap(prob::ODEProblem{…}, u0::Vector{…}, ::Val{…}, p::Dict{…}, ::Val{…}, t0::Float64)
       @ SciMLBase C:\Users\rieget\.julia\packages\SciMLBase\cwnDi\src\remake.jl:1042
 [18594] #_updated_u0_p_internal#766
       @ C:\Users\rieget\.julia\packages\SciMLBase\cwnDi\src\remake.jl:937 [inlined]
 [18595] _updated_u0_p_internal
       @ C:\Users\rieget\.julia\packages\SciMLBase\cwnDi\src\remake.jl:922 [inlined]
 [18596] #updated_u0_p#786
       @ C:\Users\rieget\.julia\packages\SciMLBase\cwnDi\src\remake.jl:1123 [inlined]
 [18597] updated_u0_p
       @ C:\Users\rieget\.julia\packages\SciMLBase\cwnDi\src\remake.jl:1102 [inlined]
 [18598] remake(prob::ODEProblem{…}; f::Function, u0::Vector{…}, tspan::Tuple{…}, p::Dict{…}, kwargs::Missing, interpret_symbolicmap::Bool, build_initializeprob::Type, use_defaults::Bool, lazy_initialization::Nothing, _kwargs::@Kwargs{})
       @ SciMLBase C:\Users\rieget\.julia\packages\SciMLBase\cwnDi\src\remake.jl:228
 [18599] get_concrete_problem(prob::ODEProblem{…}, isadapt::Bool; kwargs::@Kwargs{…})
       @ DiffEqBase C:\Users\rieget\.julia\packages\DiffEqBase\VCM6X\src\solve.jl:1316
 [18600] solve_up(prob::ODEProblem{…}, sensealg::Nothing, u0::Vector{…}, p::Dict{…}, args::QNDF{…}; kwargs::@Kwargs{…})
       @ DiffEqBase C:\Users\rieget\.julia\packages\DiffEqBase\VCM6X\src\solve.jl:1193
Some type information was truncated. Use `show(err)` to see complete types.

My package information:

(scratch) pkg> status
Status `C:\Users\rieget\Documents\GitHub\scratch\Project.toml`
  [13f3f980] CairoMakie v0.13.4
  [1313f7d8] DataFramesMeta v0.15.4
  [459566f4] DiffEqCallbacks v4.4.1
  [0c46a032] DifferentialEquations v7.16.1
  [91a5bcdd] Plots v1.40.13
  [0bca4576] SciMLBase v2.85.0
  [2cb19f9e] StatsKit v0.3.1

(scratch) pkg> 

My versioninfo:

julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b73 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 20 × 12th Gen Intel(R) Core(TM) i7-1280P
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 6 default, 0 interactive, 3 GC (on 20 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 6

This is a bug. @cryptic.ax dicts shouldn’t cause this code path if there’s no MTK system?

Oof, yeah this is not a nice bug. I’ll fix it ASAP.

1 Like