AndreaBozzo opened a new pull request, #12010:
URL: https://github.com/apache/arrow-rs/pull/12010

   # Which issue does this PR close?
   
   - Closes #7136.
   
   # Rationale for this change
   
   Since #10030, `from_ffi` realigns under-aligned buffers, but `buffer_len` 
reads the last offset of a `Utf8`, `Binary`, `LargeUtf8` or `LargeBinary` array 
through an aligned dereference before that runs. Offsets that are not aligned 
for `i32` or `i64`, which the C data interface allows, abort a debug build with 
a misaligned pointer dereference and are undefined behaviour in release. Found 
with [arrow-abi-doctor](https://github.com/AndreaBozzo/arrow-abi-doctor), whose 
alignment cells place `utf8` offsets one byte off.
   
   # What changes are included in this PR?
   
   The two offset reads in `ImportedArrowArray::buffer_len` use 
`read_unaligned`.
   
   # Are these changes tested?
   
   Yes. `test_bytes_with_unaligned_offsets` imports a hand-built C array of 
each of the four types with its offsets one byte off alignment. Reverting 
either read makes it abort.
   
   # Are there any significant user-facing changes?
   
   No.
   


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