Skip to content

GH-51018: [C++] Fix indices_nonzero segfault on chunkless ChunkedArray - #51021

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/nonzero-zero-chunks-51018
Open

GH-51018: [C++] Fix indices_nonzero segfault on chunkless ChunkedArray#51021
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/nonzero-zero-chunks-51018

Conversation

@waterWang

@waterWang waterWang commented Aug 28, 2026

Copy link
Copy Markdown

Rationale for this change

pyarrow.compute.indices_nonzero() segfaults (SIGSEGV) on a ChunkedArray with zero chunks. A zero-length Array and a ChunkedArray holding one empty chunk both work; only the chunkless case crashes.

Are these changes tested?

Yes, by new test case.

Are there any user-facing changes?

Only a bugfix.

…edArray

Calling indices_nonzero on a ChunkedArray with zero chunks (e.g. the shape
produced by filtering a table down to no rows) segfaulted. IndicesNonZeroExecChunked
built an empty vector of ArraySpans, and DoNonZero unconditionally dereferenced
arrays[0].type, performing an out-of-bounds vector access.

Guard DoNonZero so an empty chunk vector yields an empty result, consistent with
the zero-length Array and single-empty-chunk cases.
@pitrou

pitrou commented Aug 31, 2026

Copy link
Copy Markdown
Member

Thanks @waterWang . I've trimmed the verbosity from the PR message (was it AI-generated?) and will merge if CI is green.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Aug 31, 2026
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.

2 participants