Skip to content
Snippets Groups Projects
user avatar
Vladislav Shpilevoy authored
Lib/bit library in some functions dereferenced a byte array as a
pointer at uint64 or uint32. It led to unaligned memory access,
when the array didn't have the needed alignment. That made clang
'alignment' sanitizer crazy.

Also there were places, where bitwise shift was done for the type
size. For example, a uint32 number was allowed to make 32 bit
shift in both sides. This is undefined behaviour.

The patch fixes these UBs. Bitwise shift of too long size is
banned. Unaligned access is fixed in some places by changing
uint64 to uint8, when it is possible without perf loss. And in the
others by using explicitly specified unaligned load. So it works
the same, but the sanitizer is aware of that.

Part of #4609

Reviewed-by: default avatarAleksandr Lyapunov <alyapunov@tarantool.org>
Reviewed-by: default avatarTimur Safin <tsafin@tarantool.org>
43a36202
History
Name Last commit Last update