Repository navigation
GH-54937: [C++] Fix DenseUnionArray::Make for sliced type_ids and value_offsets arrays - #54940
Closed
JonSnow1807 wants to merge 1 commit into
Closed
JonSnow1807 wants to merge 1 commit into
JonSnow1807 wants to merge 1 commit into
Conversation
…nd value_offsets arrays DenseUnionArray::Make used type_ids.offset() as the offset of the union array for both the type ids and the value offsets buffers, and never checked the length of value_offsets. With a value_offsets array sliced differently from type_ids the union read value offsets from the wrong positions (which ValidateFull cannot detect), and a value_offsets array shorter than type_ids was accepted. Reject value_offsets arrays shorter than type_ids, slice both buffers to their logical windows (zero-copy) when the inputs are sliced, and build the union with offset 0. Unsliced inputs keep using the original buffers.
|
|
|
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: |
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
DenseUnionArray::Makeusedtype_ids.offset()as the union offset for both the type ids and the value offsets buffers, and never checked the length ofvalue_offsets. With avalue_offsetsarray that is sliced differently fromtype_idsthe union reads value offsets from the wrong positions (andValidateFullcannot tell), and a too-shortvalue_offsetsarray is accepted. See GH-54937; same root cause as GH-54907 (#54938).What changes are included in this PR?
DenseUnionArray::MakereturnsInvalidwhenvalue_offsetsis shorter thantype_ids. A longervalue_offsetsarray is still tolerated (only the firstlen(type_ids)offsets are used), since existing callers rely on that.type_idsorvalue_offsetsis sliced, its buffer is sliced (zero-copy) to the logical window and the union is built with offset 0. Unsliced inputs keep using the original buffers.TestUnionArrayFactories.TestMakeDenseSliced.Are these changes tested?
Yes. The new test fails on main (sliced
value_offsetsyields[10, 20]instead of[20, 30], and the shortvalue_offsetsarray is accepted) and passes with the fix.arrow-array-test,arrow-ipc-read-write-test,arrow-scalar-testandarrow-compute-scalar-type-testpass locally (Debug, ASan/UBSan).Are there any user-facing changes?
DenseUnionArray::Makenow returnsInvalidwhenvalue_offsetsis shorter thantype_ids, and the resulting array has offset 0 instead oftype_ids.offset().AI usage disclosure: Claude Code assisted with investigating the root cause, preparing the implementation, and developing the regression test. I reviewed the changes and am responsible for their correctness.