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

   ### Rationale for this change
   
   `WritePayload()` and `ReadPayload()` pass a `FlightPayload` or 
`internal::FlightData` to gRPC as a `pb::FlightData` through 
`reinterpret_cast`, and `SerializationTraits<pb::FlightData>` casts it back. 
The object is not a `pb::FlightData`, which is undefined behavior and which 
Clang CFI (`-fsanitize=cfi-unrelated-cast`) rejects. We found this in 
ClickHouse, which embeds Arrow and is enabling Clang CFI in its release builds.
   
   ### What changes are included in this PR?
   
   gRPC only passes the message to `SerializationTraits<pb::FlightData>`, which 
we control. So instead of a cast, `WritePayload()` and `ReadPayload()` give 
gRPC an empty, real `pb::FlightData` that sits next to a pointer to the Arrow 
struct, and the traits read the struct back through `FlightPayloadOfMessage()` 
and `FlightDataOfMessage()`. No protobuf message is built or serialized, so the 
zero-copy path is unchanged.
   
   ### Are these changes tested?
   
   By the existing `arrow-flight-test`, built with `-flto=thin 
-fwhole-program-vtables -fvisibility=hidden -fsanitize=cfi 
-fno-sanitize-trap=cfi -fsanitize-recover=cfi`. Before: all 94 tests pass, with 
9 CFI reports on `arrow::flight::protocol::FlightData` (the 8 casts in 
`serialization_internal.cc`, and `grpc/impl/call_op_set.h` on the same object). 
After: all 94 tests pass and those reports are gone.
   
   ### Are there any user-facing changes?
   
   No.
   
   ### Was AI used for this PR?
   
   **PR code and description written by:**
   
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   
   - [x] Human
   - [ ] AI
   - [ ] Not reviewed
   * GitHub Issue: #55479
   


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