Repository navigation
Conversation
|
|
pitrou
requested changes
Oct 13, 2026
dmitry-chirkov-dremio
suggested changes
Oct 21, 2026
…p and bounds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dricmoy
force-pushed
the
gh-51222-binary-slice-overflow
branch
from
November 11, 2026 22:18
61c9a9c to
6c0d83f
Compare
Contributor
Author
|
Thanks for the reviews. Updated and rebased onto main:
Tested with ASan + UBSan. I also ran a local, uncommitted comparison against Python slice semantics over ~20k start/stop/step combinations. AI disclosure: I used Claude to find the remaining overflow paths and to draft the change and tests. I've reviewed all of it.
|
dmitry-chirkov-dremio
approved these changes
Nov 13, 2026
dmitry-chirkov-dremio
left a comment
Contributor
There was a problem hiding this comment.
Lgtm. My earlier feedback is addressed. @pitrou's too it seems?
Contributor
Author
|
@pitrou Could you take another look? I addressed your comments, and Dmitry has approved. |
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.
Rationale for this change
binary_sliceusesINT64_MAXas its default stop, and several internal calculations usedstart,stopandstepdirectly. With large values they overflowed. That causedArrowInvalid: Negative buffer resizefor valid calls likebinary_slice(values, 1), wrong output, and crashes in release builds (e.g.step=INT64_MIN).Closes #51222.
What changes are included in this PR?
MaxSliceBytesclamps start/stop to[-len - 1, len], andNumSelectedBytescomputesceil(span / |step|)without overflow.SliceBackwardRangeclamps before adding 1.FixedOutputSizeusesNumSelectedBytes.The slicing rules and public API are unchanged.
Are these changes tested?
Yes. Cases with
INT64_MIN/INT64_MAXstart, stop and step are added to the existing binary and fixed-size-binary slice tests.arrow-compute-scalar-type-testpasses under ASan + UBSan.Are there any user-facing changes?
binary_slicewith extremestart/stop/stepreturns the correct slice instead of raising, returning wrong bytes, or crashing.This PR contains a "Critical Fix".
binary_slicecould return incorrect data or crash for validSliceOptionswith extremestart/stop/step.utf8_slice_codeunitshas a similar overflow, tracked separately in #55509.Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
Yes. OpenAI Codex helped with the initial fix. Claude helped find the remaining overflow paths and write the follow-up change and tests. I reviewed all of it and take responsibility for the contribution.
PR code and description written by:
Reviewed before submission by:
stopraises "Negative buffer resize" #51222