singhpratech opened a new issue, #51222:
URL: https://github.com/apache/arrow/issues/51222

   **Describe the bug**
   
   `pyarrow.compute.binary_slice(arr, start)` with `stop` left at its default 
raises
   `ArrowInvalid: Negative buffer resize` once a value is longer than a few 
hundred bytes. Passing an
   explicit large `stop` works, and `utf8_slice_codeunits` handles the same 
default correctly since
   #36575; the binary kernel still has the overflow in its output-size 
arithmetic.
   
   pyarrow 25.0.1, Python 3.13.9, macOS 26.6 (arm64), wheel from PyPI.
   
   ```python
   import pyarrow as pa, pyarrow.compute as pc
   
   b = pa.array([b"abcdef", b"x" * 300], pa.binary())
   print([len(x) for x in pc.binary_slice(b, 1, 1000).to_pylist()])   # 
explicit stop: fine
   print([len(x) for x in pc.utf8_slice_codeunits(pa.array(["abcdef", "x" * 
300]), 1).to_pylist()])
   print(pc.binary_slice(b, 1).to_pylist())                            # 
default stop
   ```
   
   Output:
   
   ```
   [5, 299]
   [5, 299]
   Traceback (most recent call last):
     ...
   pyarrow.lib.ArrowInvalid: Negative buffer resize: -4
   ```
   
   **Expected behavior**
   
   `binary_slice(b, 1)` returns `[b"bcdef", b"x" * 299]`, as 
`utf8_slice_codeunits` does for the string
   equivalent.
   
   Related: #34929 (umbrella for slice-option overflow), #36575 (the utf8 fix).
   
   **Component(s)**
   
   C++, Python
   


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