Repository navigation
Bounds-check ChainedVector indexing with index vectors and ranges - #130
Merged
Merged
Conversation
getindex(::ChainedVector, ::AbstractVector{Int}) never checked its
indices, so x[[0]] or x[[-1]] segfaulted and x[[length(x) + 1]] returned
garbage. The UnitRange method read before the first chunk for ranges
starting below 1 before failing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj
referenced
this pull request
Oct 27, 2026
Bump to 1.4.11. Also fixes a test guard: findmax(f, x) and non-Integer isodd need Julia 1.7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Indexing a
ChainedVectorwith an index vector never checked bounds, so a bad index read arbitrary memory instead of throwing:This happens without
@inbounds. TheUnitRangemethod also read before the first chunk for ranges starting below 1, though it then threw aBoundsErrorfrom a later checked access.Both methods now start with
@boundscheck checkbounds(x, inds), like the scalar method and Base's owngetindex. Under@inboundsthe check is skipped as before.Verification: new tests cover
[0],[4],[1, 4],[-1],0:1,3:4and-1:0; full suite passes locally on Julia 1.3.1 and 1.12.6. Gathering 500,000 sorted indices from a 1M-element, 64-chunk vector takes the same time before and after (about 1.6 ms, within noise on a loaded machine). Merges cleanly before or after the other open ChainedVector PRs.🤖 Generated with Claude Code