waterWang opened a new pull request, #51021:
URL: https://github.com/apache/arrow/pull/51021

   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   * Closes: #51018
   
   ### Rationale for this change
   
   `pyarrow.compute.indices_nonzero()` segfaults (SIGSEGV) on a `ChunkedArray`
   with **zero chunks** — the shape produced by filtering a table to no rows or
   slicing zero rows. Reproduced on pyarrow 18.1.0 through 25.0.1. A zero-length
   `Array` and a `ChunkedArray` holding one empty chunk both work; only the
   chunkless case crashes.
   
   ### What changes are included in this PR?
   
   `IndicesNonZeroExecChunked` builds a `std::vector<ArraySpan>` from the 
chunks;
   for a zero-chunk array that vector is empty. `DoNonZero` unconditionally
   dereferenced `arrays[0].type`, an out-of-bounds vector access. Guard 
`DoNonZero`
   so an empty chunk vector returns an empty result, consistent with the other
   empty-input paths.
   
   ### Are these changes tested?
   
   Yes — added a zero-chunk case to `TestIndicesNonZero.IndicesNonZero` that
   asserts `indices_nonzero` on `ChunkedArray({}, type)` returns `[]` for every
   numeric type. The crash reproduces locally on pyarrow 25.0.1 (SIGSEGV); with
   the fix the same call returns an empty array.
   
   * Closes: #51018


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to