Suppress UBSAN error in finer guanularity
Summary: Now we suppress alignment UBSAN error as a whole. Suppressing 3-way CRC and murmurhash feels a better idea than turning off alignment check as a whole. Closes https://github.com/facebook/rocksdb/pull/3495 Differential Revision: D6971273 Pulled By: siying fbshipit-source-id: 080b59fed6df494b9f622ef7cb5d42d39e6a8cdf
This commit is contained in:
parent
3c380fdffd
commit
74748611a8
6
Makefile
6
Makefile
@ -236,9 +236,9 @@ ifdef COMPILE_WITH_UBSAN
|
|||||||
# memory to integer. Fixing it may cause performance regression. 3-way crc32
|
# memory to integer. Fixing it may cause performance regression. 3-way crc32
|
||||||
# relies on it too, although it can be rewritten to eliminate with minimal
|
# relies on it too, although it can be rewritten to eliminate with minimal
|
||||||
# performance regression.
|
# performance regression.
|
||||||
EXEC_LDFLAGS += -fsanitize=undefined -fno-sanitize-recover -fno-sanitize=alignment
|
EXEC_LDFLAGS += -fsanitize=undefined -fno-sanitize-recover=all
|
||||||
PLATFORM_CCFLAGS += -fsanitize=undefined -fno-sanitize-recover -fno-sanitize=alignment -DROCKSDB_UBSAN_RUN
|
PLATFORM_CCFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -DROCKSDB_UBSAN_RUN
|
||||||
PLATFORM_CXXFLAGS += -fsanitize=undefined -fno-sanitize-recover -fno-sanitize=alignment -DROCKSDB_UBSAN_RUN
|
PLATFORM_CXXFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -DROCKSDB_UBSAN_RUN
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef ROCKSDB_VALGRIND_RUN
|
ifdef ROCKSDB_VALGRIND_RUN
|
||||||
|
@ -605,6 +605,13 @@ const uint64_t clmul_constants[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Compute the crc32c value for buffer smaller than 8
|
// Compute the crc32c value for buffer smaller than 8
|
||||||
|
#ifdef ROCKSDB_UBSAN_RUN
|
||||||
|
#if defined(__clang__)
|
||||||
|
__attribute__((__no_sanitize__("alignment")))
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
__attribute__((__no_sanitize_undefined__))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
inline void align_to_8(
|
inline void align_to_8(
|
||||||
size_t len,
|
size_t len,
|
||||||
uint64_t& crc0, // crc so far, updated on return
|
uint64_t& crc0, // crc so far, updated on return
|
||||||
@ -649,6 +656,13 @@ inline uint64_t CombineCRC(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute CRC-32C using the Intel hardware instruction.
|
// Compute CRC-32C using the Intel hardware instruction.
|
||||||
|
#ifdef ROCKSDB_UBSAN_RUN
|
||||||
|
#if defined(__clang__)
|
||||||
|
__attribute__((__no_sanitize__("alignment")))
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
__attribute__((__no_sanitize_undefined__))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
uint32_t crc32c_3way(uint32_t crc, const char* buf, size_t len) {
|
uint32_t crc32c_3way(uint32_t crc, const char* buf, size_t len) {
|
||||||
const unsigned char* next = (const unsigned char*)buf;
|
const unsigned char* next = (const unsigned char*)buf;
|
||||||
uint64_t count;
|
uint64_t count;
|
||||||
|
@ -20,6 +20,13 @@
|
|||||||
//
|
//
|
||||||
// 64-bit hash for 64-bit platforms
|
// 64-bit hash for 64-bit platforms
|
||||||
|
|
||||||
|
#ifdef ROCKSDB_UBSAN_RUN
|
||||||
|
#if defined(__clang__)
|
||||||
|
__attribute__((__no_sanitize__("alignment")))
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
__attribute__((__no_sanitize_undefined__))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed )
|
uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed )
|
||||||
{
|
{
|
||||||
const uint64_t m = 0xc6a4a7935bd1e995;
|
const uint64_t m = 0xc6a4a7935bd1e995;
|
||||||
|
Loading…
Reference in New Issue
Block a user