hcrosse opened a new issue, #1614:
URL: https://github.com/apache/arrow-go/issues/1614

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   `BinaryViewBuilder` and `StringViewBuilder` can produce arrays that pass 
`ValidateFull` but panic when reading a value that ends at byte 2147483648 of a 
data block.
   
   I reproduced this on v18.9.0 and main, with Go 1.26.10 on macOS arm64. The 
reproduction needs about 4 GiB of memory.
   
   With a `BinaryViewBuilder` named `b`:
   
   ```go
   b.Append(bytes.Repeat([]byte("x"), 2147483600))
   b.Append(bytes.Repeat([]byte("x"), 48))
   arr := b.NewBinaryViewArray()
   fmt.Println(arr.ValidateFull())
   arr.Value(1)
   ```
   
   ```text
   <nil>
   panic: runtime error: slice bounds out of range [:-2147483648]
   ```
   
   `Value(1)` should return the second value.
   
   Calling `SetBlockSize` with a value above `MaxInt32` can also produce 
negative offsets.
   
   **Cause**
   
   `memory.Buffer` rounds the first block up to 2147483648 bytes, and the 
builder counts that extra space as room, so the second value ends at byte 
2147483648. The readers add the offset and length in `int32`, which overflows 
even though validation accepts the array.
   
   
https://github.com/apache/arrow-go/blob/1cfb8bd743b391747702156d75b2b804ae22cab1/arrow/array/bufferbuilder.go#L199-L212
   
   
https://github.com/apache/arrow-go/blob/1cfb8bd743b391747702156d75b2b804ae22cab1/arrow/array/binary.go#L606-L614
   
   ### Component(s)
   
   Other
   


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