Skip to content

Comments

GH-49310: [C++][Compute] Fix segmentation fault in pyarrow.compute.if_else#49375

Open
Anakin100100 wants to merge 2 commits intoapache:mainfrom
Anakin100100:fix/compute-if-else-array-overflow
Open

GH-49310: [C++][Compute] Fix segmentation fault in pyarrow.compute.if_else#49375
Anakin100100 wants to merge 2 commits intoapache:mainfrom
Anakin100100:fix/compute-if-else-array-overflow

Conversation

@Anakin100100
Copy link
Contributor

@Anakin100100 Anakin100100 commented Feb 23, 2026

Rationale for this change

Fixing #49310

What changes are included in this PR?

I added a check for the if else compute kernels that verify that the result will fit in the offset of the result. The check asserts that no matter which values are chosen from either the left or right arrays/scalars there will be no overflow in order to use the UnsafeAppend which skips almost all safety checks.

Are these changes tested?

Yes, There are tests for each of the kernels that include an array that the values that would overflow the 32 bit index trigger the check. These tests don't actually allocate the data to save on time and compute. There are also two tests that verify an overflow for a 32 bit offset type and trigger an error and the second one that ensures that for a data type with a 64 bit offset there is no overflow error.

Are there any user-facing changes?

Yes, if the result may not fit in a type that relies on 32 bit offsets the user will receive a helpful error message instead of a segfault.

@github-actions
Copy link

⚠️ GitHub issue #49310 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant