Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined behavior in serialization #42

Open
asherikov opened this issue Dec 6, 2024 · 0 comments
Open

undefined behavior in serialization #42

asherikov opened this issue Dec 6, 2024 · 0 comments

Comments

@asherikov
Copy link

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 #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant