Repository navigation
GH-54916: [C++][IPC] Align metadata in Message::Open - #54917
Open
Spikhalskiy wants to merge 1 commit into
Open
Spikhalskiy wants to merge 1 commit into
Spikhalskiy wants to merge 1 commit into
Conversation
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.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
ipc::Message::Open()verifies and reads the Flatbuffers metadata in place. Flight passes it adata_headersliced 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 onlyMessageDecodercalls it.What changes are included in this PR?
MessageImpl::Open()now callsMaybeAlignMetadata()before verifying the metadata. Aligned metadata, including everything that comes throughMessageDecoder, is not copied.Are these changes tested?
Yes, test is added in this PR.
TestMessage.OpenUnalignedMetadataopens a message whose metadata starts at an odd address and checks that it round-trips and thatMessage::metadata()is 8-byte aligned. Without the fix the alignment check fails, and under-fsanitize=alignmentthe test reports misaligned accesses inVerifyMessageandGetKeyValueMetadata. 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 toMessage::Open().Was AI used for this PR?
PR code and description written by:
Reviewed before submission by:
Closes #54916