[AVRO-4248] Fix misaligned pointer use in BufferDetail.hh and BufferReader.hh#3740
[AVRO-4248] Fix misaligned pointer use in BufferDetail.hh and BufferReader.hh#3740apilloud wants to merge 1 commit intoapache:mainfrom
Conversation
| memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T)); | ||
| postWrite(sizeof(T)); | ||
| } else { | ||
| // need to fixup chunks first, so use the regular memcpy |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
The actual implementation of writeTo is a memcpy:
https://github.com/apache/avro/pull/3740/changes/BASE..14aa89a4aded2b202e6402a6c277d40ed7cfd5b2#diff-e480d7690c296659bf5547ee3c64047c8902d7f9343c55f404b985b383d3ae66R351
|
Is there a way to verify the improvement with a (unit) test ? |
| memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T)); | ||
| postWrite(sizeof(T)); | ||
| } else { | ||
| // need to fixup chunks first, so use the regular memcpy |
There was a problem hiding this comment.
The actual implementation of writeTo is a memcpy:
https://github.com/apache/avro/pull/3740/changes/BASE..14aa89a4aded2b202e6402a6c277d40ed7cfd5b2#diff-e480d7690c296659bf5547ee3c64047c8902d7f9343c55f404b985b383d3ae66R351
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