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

   ### Rationale for this change
   
   `ipc::Message::Open()` verifies and reads the Flatbuffers metadata in place. 
Flight passes it a `data_header` sliced zero-copy out of the gRPC message, 
which can start at any address, so Flatbuffers performs misaligned loads 
(reported by `-fsanitize=alignment`). `MaybeAlignMetadata()` already exists for 
this, but only `MessageDecoder` calls it.
   
   ### What changes are included in this PR?
   
   `MessageImpl::Open()` now calls `MaybeAlignMetadata()` before verifying the 
metadata. Aligned metadata, including everything that comes through 
`MessageDecoder`, is not copied.
   
   ### Are these changes tested?
   
   Yes. `TestMessage.OpenUnalignedMetadata` opens a message whose metadata 
starts at an odd address and checks that it round-trips and that 
`Message::metadata()` is 8-byte aligned. Without the fix the alignment check 
fails, and under `-fsanitize=alignment` the test reports misaligned accesses in 
`VerifyMessage` and `GetKeyValueMetadata`. With the fix it passes cleanly.
   
   ### Are there any user-facing changes?
   
   No. `Message::metadata()` may now return an aligned copy instead of the 
buffer passed to `Message::Open()`.
   
   ### Was AI used for this PR?
   
   **PR code and description written by:**
   
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   
   - [x] Human
   - [ ] AI
   - [ ] Not reviewed
   
   Closes #54916
   


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