Skip to content

Fix Clang CFI violations in Flight and the C data interface helpers - #92

Merged
Algunenano merged 2 commits into
ClickHouse/apache-arrow-25.0.0from
cfi-fixes
Nov 10, 2026
Merged

Algunenano merged 2 commits into
ClickHouse/apache-arrow-25.0.0from
cfi-fixes

Conversation

@Algunenano

Copy link
Copy Markdown
Member

🤖 Two changes needed to build Arrow with Clang CFI.

WritePayload and ReadPayload in the Flight gRPC transport passed a FlightPayload or internal::FlightData to gRPC as a pb::FlightData through reinterpret_cast, and SerializationTraits<pb::FlightData> cast it back. The object is not a pb::FlightData, which is undefined behavior and which Clang CFI (-fsanitize=cfi-unrelated-cast) rejects. They now give gRPC an empty, real pb::FlightData that sits next to a pointer to the Arrow struct, and the traits read the struct back from it. The same change is proposed upstream: apache#55480

The release callback of an ArrowSchema or ArrowArray can be implemented outside the code built with Clang CFI, for example in Rust, and then has no CFI type. ArrowSchemaRelease and ArrowArrayRelease are exempted from cfi-icall for that call. This one stays local.

Algunenano and others added 2 commits November 10, 2026 17:17
…ucts

`WritePayload` and `ReadPayload` passed a `FlightPayload` or
`internal::FlightData` to gRPC as a `pb::FlightData` through
`reinterpret_cast`, and `SerializationTraits<pb::FlightData>` cast it
back. The object is not a `pb::FlightData`, which is undefined behavior
and which Clang CFI (`-fsanitize=cfi-unrelated-cast`) rejects.

gRPC only passes the message to `SerializationTraits`, so give it an
empty, real `pb::FlightData` that sits next to a pointer to the Arrow
struct, and read the struct back from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The release callback of an `ArrowSchema` or `ArrowArray` can be
implemented outside the code built with Clang CFI, for example in
another language such as Rust. It then has no CFI type, so
`ArrowSchemaRelease` and `ArrowArrayRelease` cannot check the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

This pull request has been automatically converted to a draft because its title doesn't match Arrow's required format.

If this is not a minor PR, could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

After updating the title, you can mark the pull request as ready for review.

See also:

@Algunenano
Algunenano merged commit 26706cf into ClickHouse/apache-arrow-25.0.0 Nov 10, 2026
36 of 91 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant