Repository navigation
fix(arrow-string): saturate the length in Utf8View/BinaryView substring - #12006
Merged
Merged
Conversation
A length above i64::MAX was cast with `as i64` and wrapped to a negative value, so the end landed before the start. BinaryView then panicked on the slice and Utf8View returned a bogus invalid utf-8 boundary error. Saturate the length like the LargeUtf8/LargeBinary arms do.
Rich-T-kid
self-requested a review
November 1, 2026 22:54
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.
Which issue does this PR close?
substringarms saturate large lengths. TheUtf8View/BinaryViewarms added in Support Utf8View and BinaryView in substring #10672 were missed.Rationale for this change
view_substring_rangecomputed the end asnew_start.saturating_add(length as i64). Forlength > i64::MAXthe cast wraps negative, so the end lands before the start:substring(&BinaryViewArray["hello"], 1, Some(u64::MAX))panics withslice index starts at 1 but ends at 0;StringViewArrayreturnsComputeError("The offset 9223372036854775808 is at an invalid utf-8 boundary.").LargeUtf8andLargeBinaryreturn"ello"for the same input.What changes are included in this PR?
Use the existing
u64_to_i64_saturating(length)inview_substring_range, like the other arms.Are these changes tested?
Yes. A new test checks that
Utf8ViewmatchesLargeUtf8andBinaryViewmatchesLargeBinaryfor several starts (including negative and beyond the end) with lengths2^63andu64::MAX.Are there any significant user-facing changes?
No.
AI disclosure: the bug was found and the patch and test drafted with AI assistance (Claude); I reviewed every line, verified the failing test before/after the fix, and ran fmt/clippy/tests for the crate.