Repository navigation
Reject wrong-length out for idxs=nothing interpolation - #4639
Merged
ChrisRackauckas merged 3 commits intoSep 27, 2026
Merged
Conversation
ChrisRackauckas-Claude
force-pushed
the
interp-out-size
branch
4 times, most recently
from
September 27, 2026 04:10
3adf6d7 to
435460f
Compare
ChrisRackauckas
marked this pull request as ready for review
September 27, 2026 14:43
With idxs === nothing the in-place dense kernels loop over out under @inbounds with no length check against the state, so a short out silently truncates and a long out OOB-reads state. Require length(out) == length(u) against the interpolated interval's states (timeseries[i₋]/[i₊], integrator.uprev/u), per requested time in the vector path — not timeseries[1], which breaks after callback resize!. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent 2026.09.26-dd393fe Agent-Model: auto Agent-Session: local cursor-agent session in /home/crackauc/sandbox/goals/performance/jobs/pr-out-size/repo (log /home/crackauc/sandbox/goals/performance/jobs/pr-out-size/log.txt)
The idxs===nothing length guard read vals[j] before choosing the
mutate-in-place vs replace-slot path, so Vector{Any}/BigFloat(undef)
buffers that only need _set_val! threw UndefRefError. Read and length-
check only on AbstractArray element paths; validate idxs vs state
without reading the slot on the replace path.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local cursor-agent session in /home/crackauc/sandbox/goals/performance/jobs/pr-out-size/repo (log /home/crackauc/sandbox/goals/performance/jobs/pr-out-size/log.txt)
Mirror SciML#4607's eachindex(tvals) over-long buffer coverage for the idxs===nothing path: extra uninitialized or wrong-length slots beyond the written range must remain untouched, matching master. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent 2026.09.26-dd393fe Agent-Model: auto Agent-Session: local cursor-agent session in /home/crackauc/sandbox/goals/performance/jobs/pr-out-size/repo (log /home/crackauc/sandbox/goals/performance/jobs/pr-out-size/log6.txt)
ChrisRackauckas
force-pushed
the
interp-out-size
branch
from
September 27, 2026 14:44
435460f to
96d9b89
Compare
ChrisRackauckas
referenced
this pull request
Sep 29, 2026
* Bump DiffEqBase to 7.21.3 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json * Bump OrdinaryDiffEqBDF to 2.4.12 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json * Bump OrdinaryDiffEqSDIRK to 2.9.7 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json * Bump OrdinaryDiffEqRosenbrock to 2.7.5 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json * Bump OrdinaryDiffEqLowOrderRK to 2.2.6 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json * Bump OrdinaryDiffEqTsit5 to 2.1.5 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json * Bump OrdinaryDiffEqVerner to 2.4.2 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json * Bump OrdinaryDiffEqSymplecticRK to 2.2.3 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.11.3 (Mac) Agent-Model: Fusion (claude-opus-5-5 medium + swe-2 medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore until reviewed by @ChrisRackauckas.
Stacked on #4607 @
9a75ffb9f— reviewers should look only at the commits after that tip.What changed and why
With
idxs === nothing, the in-place dense_ode_interpolant!kernels loop overout's indices under@inboundswith no length check against the state. A shortoutsilently truncates; a longoutOOB-reads past the end ofu(observed as garbage like8e-310). This extends the existing entry-point guards from #4607 so that whenidxs === nothingand the state is not aNumber,length(out) == length(u)is required (via the existing@noinlineDimensionMismatchhelper). Length, not axes, so equal-length differently shaped buffers (matrix state with vectorout,ArrayPartition,ComponentArray,VectorOfArray) keep working.Reference state (Astra review): the length check must use the same interpolated-interval states that #4607 uses for
idxs—timeseries[i₋]/timeseries[i₊]after the interval is chosen, andintegrator.uprev/integrator.uon the integrator/extrapolant paths — nottimeseries[1], which rejects a correctly sized buffer after callbackresize!and leaves a wrong-sized one unchecked after shrink.Vector-of-times: reuses #4607's per-time axes cache — one axes comparison per requested time; full
_check_interpolant_idxs_out(and idxscheckboundsrescan) only when the interval states' axes change. When axes are unchanged andidxs === nothing, still O(1)-check each time'soutlength against those axes (not a rescan). Bool-mask counting via_interpolant_idxs_countis preserved from #4607. Theidxs === nothinglength checks run only for slots ineachindex(tvals)(the main loop's written range), matching #4607 @9a75ffb9f's over-long-buffer rule: extra slots beyondlength(tvals)are never read or validated.Uninitialized scalar batch outs (Astra MERGE @
a212896eb): the vector-of-times guard must not_get_val(vals, j)on the replace-slot path (_set_val!), where slots may be uninitializedVector{Any}/Vector{BigFloat}. Read and length-validate only when_vals_eltype(vals) <: AbstractArray(mutate-in-place); on the replace path, validateidxsagainst the interval states without reading the slot. #4607 applies the same rule to theidxs !== nothingoutput-slot preflight (eachindex(tvals)@9a75ffb9f); this branch keeps both fixes.Verification
Runic
--checkexit 0;typosover the changed files exit 0.GROUP=Corefor OrdinaryDiffEqCore (Pkg.test) under both--check-bounds=yesandauto:Standalone
interpolation_idxs_bounds_tests.jl(Bool-mask, extrapolation, resize, uninitialized outs + over-long buffers from #4607, idxs=nothing over-long, uninitialized scalar batch): 89 / 89 under both--check-bounds=yesandauto(prior 79 + 5 from #4607 over-long idxs + 5 idxs=nothing over-long).scalar-undef.jl: 4 / 4 under both--check-bounds=yesandauto.Failing-before / passing-after
Prior revision on #4607 tip
1a69f7740(before Bool-mask / axes-cache): new assertions alone were 36 pass / 21 fail without the fix (yes: shorts no-throw, longsBoundsError; auto: all 21 no-throw) → 57 / 57 with the fix.Rebased onto
45804a031(adds Bool-mask tests; total suite was 67 = prior 57 + 10 Bool-mask assertions): both bounds modes 67 / 67.Uninitialized scalar batch buffers (
Vector{Any}/Vector{BigFloat}× Float64 / BigFloat state) atedb6952f2viascalar-undef.jl: 1 pass / 3 errors under both--check-bounds=yesandauto(UndefRefErrorfrom unconditional_get_val). Aftera212896ebd: 4 / 4 under both modes; full suite 71 / 71. Astra then MERGED ata212896eb.Rebased onto
5fcf6165c(adds #4607 uninitialized-outs testset; tip3adf6d71e4): suite 79 / 79 under both bounds modes.Rebased onto
9a75ffb9f(narrows #4607's up-front preflight toeachindex(tvals)). Over-longvalswithidxs=[1]failed at3adf6d71e(UndefRefError/DimensionMismatchon the extra slot) and passes after. Over-longvalswithidxs=nothingalready passed at3adf6d71e(this PR never inspected extra slots) and still passes; assertions added. Suite 89 / 89 under both bounds modes.CI-discriminating assertions (
--check-bounds=yes): shorts fail because nothing is thrown; longs fail becauseBoundsError ≠ DimensionMismatch. Under--check-bounds=autothe wrong-length cases discriminate as "no exception". Exact-sized outs after grow 2→3 / shrink 3→2 are accepted; extrapolation path covered.Before/after numbers
Unchanged from the previous revision (guard is still a length compare on already-entered paths; axes cache skips idxs rescan; scalar replace path skips the slot read). Prior microbench on the 4607 stack:
sol(out,t)×1000andinit+step!+integ(out,t)minima were noise-only vs the prior tip; allocs stayed 0 / 98.What was not verified
GROUP=ALL/ QA / GPU for OrdinaryDiffEqCoreout(guard is at the Core entry points)Risk assessment
resize!, over-long untouched extras, and uninitialized scalar batch outs) unchanged; wrong-length callers that previously truncated/OOB now throwDimensionMismatch.idxs === nothing.9a75ffb9fstack (89 / 89); resize grow/shrink; extrapolation; Bool masks / uninitialized outs / over-long buffers from Validate idxs/out in in-place interpolation entry points #4607; idxs=nothing over-long; scalar undef regressions;GROUP=Coregreen; Runic/typos clean.idxs=nothingaudit versus master found every valid-on-master call unchanged; the only new errors areDimensionMismatchfor wrong-lengthout, where master silently truncated, threw BoundsError, or segfaulted. All earlier reviewer scripts pass, and perf is not worse. The earlier Codex gpt-6-astra review (MERGE @a212896eb) found the resize, extrapolation and uninitialized-buffer issues, all fixed.🤖 Generated with Cursor Agent (model: auto)
Risk assessment
Risk: low
Blast radius: In-place solution/integrator interpolation and extrapolation across OrdinaryDiffEq solvers. Invalid indices/buffer lengths now throw instead of truncating or reading out of bounds—a disclosed behavior correction, with no signature change. No weakened tests or new non-public dependency access found.
Evidence: Head
435460f0ehas 253 passing checks and seven failures, all reproduced with matching errors on recent master commits:SciMLSensitivity.jl/Core1/1: MooncakeAnyconstructor error—pre-existing on3178b1948.downgrade-sublibraries / test (lib/DiffEqBase): callback-related assertions/errors—pre-existing on8b3a3b07a.downgrade-sublibraries / test (lib/OrdinaryDiffEqDifferentiation): missingdiag(::ScalarOperator)—pre-existing on8b3a3b07a.OrdinaryDiffEqDifferentiation,OrdinaryDiffEqNonlinearSolve, andGlobalDiffEq: respectively missingdiag, Trapezoid mass-matrix rejection, and callback rejection—pre-existing on3178b1948.DelayDiffEq [Regression] / Julia 1: Waltman matrix contains Infs/NaNs—also fails on3178b1948, although older master runs passed.Core tests on Julia 1/LTS/pre, QA, downgrade, and Core GPU pass. Top-level GPU was cancelled; master
85110ac2afails its QNDF test, so GPU equivalence remains unverified. The description omits that cancellation. No review comments exist.Independent review: Codex CLI 0.156.1 (Mac) / gpt-6-astra rated it low, high confidence: the full diff adds targeted validation and regression coverage, and all seven completed failing checks match master failures.
Merge: auto-merge candidate after its still-open prerequisite Validate idxs/out in in-place interpolation entry points #4607 merges; no demonstrated test regressions.
🤖 Risk assessment posted by an AI agent (fleet master) — harness: Codex CLI 0.156.1 (Mac) / gpt-6-astra; dispatched by Claude Code head, model claude-opus-5-5[1m]
Conversation: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 on Chris's Mac (session ID, no URL)