Skip to content

[AVRO-4248] Fix misaligned pointer use in BufferDetail.hh and BufferReader.hh#3740

Open
apilloud wants to merge 1 commit intoapache:mainfrom
apilloud:asan
Open

[AVRO-4248] Fix misaligned pointer use in BufferDetail.hh and BufferReader.hh#3740
apilloud wants to merge 1 commit intoapache:mainfrom
apilloud:asan

Conversation

@apilloud
Copy link
Copy Markdown
Member

What is the purpose of the change

Fix a misaligned pointer use by replacing cast with memcpy.

Verifying this change

Verified with same asan test that found the failure. See AVRO-4248

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@github-actions github-actions Bot added the C++ Pull Requests for C++ binding label Apr 22, 2026
memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T));
postWrite(sizeof(T));
} else {
// need to fixup chunks first, so use the regular memcpy
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the else clause the comment mentions memcpy but still uses reinterpret_cast.

I am not C++ dev, so I don't know whether this needs fixing or not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread lang/c++/include/avro/buffer/detail/BufferDetail.hh
@martin-g
Copy link
Copy Markdown
Member

Is there a way to verify the improvement with a (unit) test ?

Copy link
Copy Markdown
Member Author

@apilloud apilloud left a comment

Choose a reason for hiding this comment

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

Found and verified this by running existing tests with ASAN. See AVRO-4248 for the stacks.

Comment thread lang/c++/include/avro/buffer/detail/BufferDetail.hh
memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T));
postWrite(sizeof(T));
} else {
// need to fixup chunks first, so use the regular memcpy
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Labels

C++ Pull Requests for C++ binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants