Skip to content

Integrators_II resize test calls length on a DiffCache #4188

Description

@ChrisRackauckas-Claude

Reproduction

On an isolated detached worktree at unmodified OrdinaryDiffEq master commit 4cb802090d69e83e13a43c2490d9de40bb3216bc, Julia 1.10.11, the canonical group command fails:

GROUP=Integrators_II ~/.juliaup/bin/julia +1.10 --project=. -e 'using Pkg; Pkg.test()'

The preceding Integrators_II subgroups pass. Resize Tests then reports:

resize! with SplitODEProblem: Error During Test
Expression: length(integrator.f._func_cache) == 2
MethodError: no method matching length(
    ::PreallocationTools.DiffCache{Vector{Float64}, Vector{Float64}}
)

Test Summary:                  | Pass  Error  Total
Resize Tests                   |   89      1     90
  resize! with SplitODEProblem |    5      1      6

A focused reproduction on the same checkout is:

using OrdinaryDiffEq

f!(du, u, p, t) = du .= u
ode = SplitODEProblem(f!, f!, [1.0], (0.0, 1.0))
integrator = init(ode, Tsit5())
step!(integrator)
resize!(integrator, 2)

@show typeof(integrator.f._func_cache)
length(integrator.f._func_cache)

It prints:

PreallocationTools.DiffCache{Vector{Float64}, Vector{Float64}}
ERROR: MethodError: no method matching length(
    ::PreallocationTools.DiffCache{Vector{Float64}, Vector{Float64}}
)

The same failure occurs in the Julia 1.12.6 CI job:
https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/31294134378/job/93196369385

Introduction point

The invalid assertion was added by:
6bc9d9a

Its parent does not contain length(integrator.f._func_cache); the new line is therefore the direct introduction point for this deterministic error. _func_cache is a PreallocationTools.DiffCache, which deliberately is not an AbstractArray and has no Base.length method.

Expected fix

Keep the deterministic post-resize state initialization, but validate scratch-buffer growth through behavior or a supported cache accessor rather than calling length on the DiffCache wrapper. The test also currently emits the independent deprecation warning that u_modified!(integrator, true) should use derivative_discontinuity!(integrator, true).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions