Fix off-by-one in split_chunk upper bound - #10342
Open
JoongHyuk-Shin wants to merge 1 commit into
Open
Conversation
|
@melihmutlu, @pnthao: please review this pull request.
|
JoongHyuk-Shin
force-pushed
the
fix/split-chunk-upper-bound
branch
from
July 28, 2026 09:19
ae3ab45 to
3db55bd
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
split_chunk() splits a chunk [start, end) into [start, split_at) and [split_at, end). Per the invariant documented in the code, both resulting ranges must have length at least 1, so the valid split points are [start + 1, end - 1]. The lower bound was correct, but the upper bound required the right range to have length at least 2. This rejected split_at = end - 1 (a valid length-1 right range) and made a chunk of width 2 unsplittable via an explicit split_at, even though the default midpoint path picks and accepts that same point for a width-2 chunk. Allow split points up to end - 1 so the bounds are symmetric and match the documented invariant. Empty-range splits remain rejected.
JoongHyuk-Shin
force-pushed
the
fix/split-chunk-upper-bound
branch
from
August 1, 2026 03:10
3db55bd to
42667ca
Compare
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.
split_chunk() splits a chunk [start, end) into [start, split_at) and [split_at, end). Per the invariant documented in the code, both resulting ranges must have length at least 1, so the valid split points are [start + 1, end - 1].
The lower bound was correct, but the upper bound required the right range to have length at least 2. This rejected split_at = end - 1 (a valid length-1 right range) and made a chunk of width 2 unsplittable via an explicit split_at, even though the default midpoint path picks and accepts that same point for a width-2 chunk.
Allow split points up to end - 1 so the bounds are symmetric and match the documented invariant. Empty-range splits remain rejected.