Skip to content

Conversation

@SebastianM-C
Copy link
Member

For InitializationProblems state_values(prob) can return nothing,
so calls like

remake_buffer(prob, state_values(prob), keys(u0), values(u0))

would lead to StackOverflowErrors due to the fallback for the deprecated Dict method.

function remake_buffer(sys, oldbuffer, idxs, vals)
    remake_buffer(sys, oldbuffer, Dict(idxs .=> vals))
end

This can crash julia if depwarns are enabled. The output would look like

julia> remake(prob1, u0=prob1.u0)
┌ Warning: `remake_buffer(sys, oldbuffer, vals::Dict)` is deprecated, use `remake_buffer(sys, oldbuffer, keys(vals), values(vals))` instead.
│   caller = remake_buffer(sys::NonlinearSystem, oldbuffer::Nothing, idxs::Vector{Int64}, vals::Vector{Any}) at remake.jl:59
└ @ SymbolicIndexingInterface ~/.julia/packages/SymbolicIndexingInterface/GKI0D/src/remake.jl:59
┌ Warning: `remake_buffer(sys, oldbuffer, vals::Dict)` is deprecated, use `remake_buffer(sys, oldbuffer, keys(vals), values(vals))` instead.
│   caller = remake_buffer(sys::NonlinearSystem, oldbuffer::Nothing, idxs::Base.KeySet{Any, Dict{Any, Any}}, vals::Base.ValueIterator{Dict{Any, Any}}) at remake.jl:59
└ @ SymbolicIndexingInterface ~/.julia/packages/SymbolicIndexingInterface/GKI0D/src/remake.jl:59

[2462463] signal 6 (-6): Aborted
in expression starting at none:0
Aborted (core dumped)

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

I got the above by running

using ModelingToolkit, OrdinaryDiffEqTsit5
using SciMLBase

function experiment1_sys()
    D = ModelingToolkit.D_nounits
    t = ModelingToolkit.t_nounits
    @parameters p1 = 0.5 [tunable = true] (p23[1:2] = [1, 3.0]) [tunable = true] p4 = 3 * p1 [tunable = false] y0 = 1.2 [tunable = true]
    @variables x(t) = 2p1 y(t) = y0 z(t) = x + y

    eqs = [D(x) ~ p1 * x - p23[1] * x * y
        D(y) ~ -p23[2] * y + p4 * x * y
        z ~ x + y]

    structural_simplify(ODESystem(eqs, t, tspan=(0, 3.0), name=:sys))
end

sys1 = experiment1_sys()
prob1 = ODEProblem(sys1, [sys1.p23 => [2, 4.0]])

remake(prob1, u0=prob1.u0)

on julia 1.11.0 (I tested on Linux so far) with --depwarn=yes --check-bounds=yes

…lizationProblem`s

For `InitializationProblem`s `state_values(prob)` can return `nothing`,
so calls like `remake_buffer(prob, state_values(prob), keys(u0), values(u0))`
would lead to `StackOverflowError`s due to the fallback for the deprecated `Dict` method.
This can crash julia if depwarns are enabled.
@AayushSabharwal
Copy link
Member

The version doesn't need to be bumped, it was done twice on master

@AayushSabharwal AayushSabharwal merged commit 7b37511 into SciML:master Oct 16, 2024
14 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants