fix: disallow sliced buffer regardless of sliced direction in Buffer::into_mutable and add Buffer::is_sliced and Buffer::into_mutable_unsliced#10118
Open
rluvaton wants to merge 5 commits into
Conversation
rluvaton
added a commit
to rluvaton/arrow-rs
that referenced
this pull request
Jun 11, 2026
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?
Buffer::into_mutableis not consistent regarding sliced data and can lead to panics #10117Rationale for this change
change for
Buffer::into_mutablewill lead to panic in case of owned sliced buffer when offset is greater than 0and will lead to confusing behavior (roundtrip will have different length) when called with sliced buffer when offset is 0 but length is less than underlying data length
the addition of the
Buffer::into_mutable_unslicedis to allow getting theMutableBufferregardless of the sliced, and the user will be aware of that the returned MutableBuffer can have different length and more datathe addition of
Buffer::is_slicedso the user can know if the buffer is sliced and act accordinglyWhat changes are included in this PR?
Buffer::into_mutableto disallow converting to mutable in case of sliced buffer regardless of offsetBuffer::into_mutable_unslicedto allow the user getting the entire unsliced data inMutableBufferand the user is aware of the implicationsBuffer:is_slicedAre these changes tested?
yes
Are there any user-facing changes?
yes, new functions and 1 breaking change - call to
Buffer::into_mutablewith buffer that is sliced from 0 to not the end of the underlying data will now returnErr