annoy
annoy copied to clipboard
UBSAN issue with Hamming due misalignment
../inst/include/annoylib.h:662:18: runtime error: load of misaligned address 0x55d2429c5424 for type 'const long unsigned int', which requires 8 byte alignment
Actually this PR won't fix that issue, and I'm not sure how to even fix it. Some thoughts:
- Make sure that the memory is always aligned to 8 byte offsets, possibly using something like http://man7.org/linux/man-pages/man3/posix_memalign.3.html
- Rewrite the hamming code to use 4 byte ints instead of 8 byte ints
- Change the few places where we access
v[i]
to not use an array dereference
None of these are entirely trivial
Originally posted by @erikbern in https://github.com/spotify/annoy/pull/455#issuecomment-590152737
It should be trivial to fix, and every reasonable C++ library should be tested with ASan+MSan+TSan+UBSan+Fuzzing.