Skip to content

GH-54916: [C++][IPC] Align metadata in Message::Open - #54917

Open
Spikhalskiy wants to merge 1 commit into
apache:mainfrom
Spikhalskiy:fix-message-open-align-metadata
Open

Spikhalskiy wants to merge 1 commit into
apache:mainfrom
Spikhalskiy:fix-message-open-align-metadata

Conversation

@Spikhalskiy

@Spikhalskiy Spikhalskiy commented Oct 21, 2026 •

Copy link
Copy Markdown

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, test is added in this PR. 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
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Closes #54916

Message::Open() verified and read the Flatbuffers metadata in place, so
metadata starting at an address that is not 8-byte aligned (for example a
Flight data_header sliced zero-copy out of a gRPC message) caused misaligned
loads in Flatbuffers. Copy such metadata with the existing
MaybeAlignMetadata(), as MessageDecoder already does.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54916 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++][FlightRPC] ipc::Message::Open reads unaligned Flatbuffers metadata in place

2 participants