Invalid use of `memcpy`
Bug Summary
Line 442 of runtime/transport/src/TransportInputBuffer.cc
performs a memcpy
.
I just recompiled the framework with gcc
13.2.1, and get a new warning:
../gen/runtime/transport/src/TransportInputBuffer.cc: In member function 'virtual bool OCPI::Transport::InputBuffer::isEmpty()':
../gen/runtime/transport/src/TransportInputBuffer.cc:442:18: warning: 'void* memcpy(void*, const void*, size_t)' reading 16 bytes from a region of size 8 [-Wstringop-overread]
442 | memcpy((void*)&(getMetaData()->ocpiMetaDataWord), &mdata, sizeof(RplMetaData) );
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../gen/runtime/transport/src/TransportInputBuffer.cc:437:29: note: source object 'mdata' of size 8
437 | OCPI::OS::uint64_t mdata;
| ^~~~~
This seems rather severe, and warrants fixing.
Steps to reproduce
Might be called out on Ubuntu 22.04 during a normal install-opencpi.sh
?
If this is a very new gcc
warning, there's a chance this won't be broadly replicable until Ubuntu 24.04 comes around.
Environment info
- OpenCPI Version used: 1e397194 (develop as of DGRDMA over UDP merge)
- Operating System and version: Arch Linux
Possible fixes (Optional)
memcpy
arguments are destination, then source, then count.
It seems like changing the third argument to sizeof(mdata)
would be appropriate?
However, it's possible that we may currently be somehow relying on the undefined behaviour this is performing.
Acceptance criteria
The warning is no longer issued, and CI still completes successfully.
Edited by Dom