Repository navigation
[C++][Compute] Ignore null view sizes when casting binary_view to binary - #54640
Nayana-Naik73 wants to merge 1 commit into
Conversation
|
Thanks for opening a pull request! This pull request has been automatically converted to a draft because its title doesn't match Arrow's required format. If this is not a minor PR, could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or After updating the title, you can mark the pull request as ready for review. See also: |
|
Thanks for opening a pull request! This pull request has been automatically closed because you currently have 4 open pull requests, which is more than the limit of 3. Due to the increase in pull requests opened by AI bots, and in order to keep the review queue manageable, Apache Arrow limits contributors without repository access to at most 3 concurrently open pull requests. This helps make sure each pull request gets the attention it needs and that work in progress does not go stale. Once one of your other open pull requests has been merged or closed, you are welcome to reopen this one. See also: |
Rationale for this change
The view to offset-string cast (
binary_view/utf8_viewtobinary,utf8,large_binary,large_utf8) reserves the output data buffer withSumOfBinaryViewSizesover every view, null slots included, and then copies each non-null value withUnsafeAppend. Views under a null bit are undefined andValidateFullskips them, so a null view carrying a negative size (for example one read from an IPC or Parquet file) shrinks the reservation and the cast writes past the end of the output buffer. With["foofoofoofoofoo", null, "barbarbarbarbarbarbar"]and size -36 on the null view, the array passesValidateFull()and ASan reports a WRITE overflow inBufferBuilder::UnsafeAppendfromBinaryToBinaryCastExec.What changes are included in this PR?
The reservation now only sums the sizes of valid views, walking the validity bitmap with
VisitSetBitRunsVoid.Are these changes tested?
Yes.
Cast.BinaryViewToBinaryNullViewSizebuilds aValidateFull-cleanutf8_view/binary_viewarray with a negative size on the null view and casts it to all four offset types. It fails under ASan before the change and passes after; the rest ofarrow-compute-scalar-cast-testpasses too.Are there any user-facing changes?
No.
This PR contains a "Critical Fix". It fixes an out-of-bounds heap write in
caston valid input data whose null views hold a negative size.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.
PR code and description written by:
Reviewed before submission by: