From d9cd33516a3ddf92e3a83cc996554e2a2848c33c Mon Sep 17 00:00:00 2001 From: sdong Date: Fri, 8 May 2020 14:11:03 -0700 Subject: [PATCH] Suppress UBSAN warning in CRC32 ARM (#6827) Summary: UBSAN shows following warning: util/crc32c_arm64.cc:111:11: runtime error: load of misaligned address 0x00001afcda86 for type 'const uint64_t', which requires 8 byte alignment 0x00001afcda86: note: pointer points here cc c1 2d 00 01 81 40 24 30 66 39 66 30 37 30 63 2d 32 36 63 34 2d 34 62 61 61 2d 38 35 33 31 2d ^ Suppress it just as what we do in x86 CRC. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6827 Test Plan: Run the same UBSAN and see it to pass now. Reviewed By: ltamasi Differential Revision: D21471838 fbshipit-source-id: 02943dd39a7030d2b03e5d894dcb23ed72b6c9c3 --- util/crc32c_arm64.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/crc32c_arm64.cc b/util/crc32c_arm64.cc index 61b2ccaba..7df01e6bb 100644 --- a/util/crc32c_arm64.cc +++ b/util/crc32c_arm64.cc @@ -44,6 +44,13 @@ uint32_t crc32c_runtime_check(void) { #endif } +#ifdef ROCKSDB_UBSAN_RUN +#if defined(__clang__) +__attribute__((__no_sanitize__("alignment"))) +#elif defined(__GNUC__) +__attribute__((__no_sanitize_undefined__)) +#endif +#endif uint32_t crc32c_arm64(uint32_t crc, unsigned char const *data, unsigned len) { const uint8_t *buf8;