fenfeng9 commented on issue #49740:
URL: https://github.com/apache/arrow/issues/49740#issuecomment-4689460246

   A smaller reproduction case:
   Casting short binary values to `binary_view` produces an array whose third 
buffer slot is `None` (`[None, 32, None]`). 
   
   And `validate(full=True)` still succeeds, but `_export_to_c` segfaults when 
exporting that null variadic buffer slot.
   
   ### Reproduce
   ```python
   import ctypes
   import platform
   import pyarrow as pa
   
   
   if __name__ == "__main__":
       print(f"Python {platform.python_version()}, PyArrow {pa.__version__}", 
flush=True)
       print(flush=True)
   
       arr = pa.array([b"a", b"e"], type=pa.binary())
       print("binary array:", flush=True)
       print(arr, flush=True)
       print(
           f"binary buffers      : {[None if buf is None else buf.size for buf 
in arr.buffers()]}",
           flush=True,
       )
   
       arr = arr.cast(pa.binary_view())
       print()
       print("after cast to binary_view:", flush=True)
       print(arr, flush=True)
       print(
           f"binary_view buffers : {[None if buf is None else buf.size for buf 
in arr.buffers()]}",
           flush=True,
       )
   
       arr.validate(full=True)
       print("validate(full=True) : OK", flush=True)
   
       print("_export_to_c        : calling", flush=True)
       out = ctypes.create_string_buffer(1024)
       arr._export_to_c(ctypes.addressof(out))
       print("_export_to_c        : OK", flush=True)
   ```
   
   ### Result
   ```python
   Python 3.12.13, PyArrow 24.0.0
   
   binary array:
   [
     61,
     65
   ]
   binary buffers      : [None, 12, 2]
   
   after cast to binary_view:
   [
     61,
     65
   ]
   binary_view buffers : [None, 32, None]
   validate(full=True) : OK
   _export_to_c        : calling
   ```


-- 
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