data_tamer icon indicating copy to clipboard operation
data_tamer copied to clipboard

undefined behavior in serialization

Open asherikov opened this issue 10 months ago • 0 comments

Casting buffer memory to a serialized data type in https://github.com/PickNikRobotics/data_tamer/blob/main/data_tamer_cpp/include/data_tamer/contrib/SerializeMe.hpp#L493 is undefined behavior due to alignment requirements, see https://en.cppreference.com/w/cpp/language/ub and https://stackoverflow.com/questions/55560713/ubsan-store-to-misaligned-address-what-is-the-problem-and-should-i-care, e.g., doubles must be 8 byte aligned.

The source variable should be memcpy()d to the destination instead.

PS: another reason to consider https://github.com/PickNikRobotics/data_tamer/issues/34

asherikov avatar Dec 06 '24 13:12 asherikov