]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
disable UBSAN for functions with intentional -ve shift / overflow
authorIslam AbdelRahman <tec@fb.com>
Tue, 29 Nov 2016 01:46:35 +0000 (17:46 -0800)
committerIslam AbdelRahman <tec@fb.com>
Tue, 29 Nov 2016 02:20:38 +0000 (18:20 -0800)
Summary:
disable UBSAN for functions with intentional left shift on -ve number / overflow

These functions are
rocksdb:: Hash
FixedLengthColBufEncoder::Append
FaultInjectionTest:: Key
Closes https://github.com/facebook/rocksdb/pull/1577

Differential Revision: D4240801

Pulled By: IslamAbdelRahman

fbshipit-source-id: 3e1caf6

db/fault_injection_test.cc
util/hash.cc
utilities/col_buf_encoder.cc

index 8200de1b6d66c91d80c3926f96166f7729cf6ca6..d06db2847d1a739277107f05429c27265a2fe8bd 100644 (file)
@@ -228,6 +228,11 @@ class FaultInjectionTest : public testing::Test,
     return Status::OK();
   }
 
+#if defined(__clang__)
+__attribute__((__no_sanitize__("undefined")))
+#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
+__attribute__((__no_sanitize_undefined__))
+#endif
   // Return the ith key
   Slice Key(int i, std::string* storage) const {
     int num = i;
index dfd2dc40367da0fdc4f03af1e9181772e7b5f9bd..ce0790a8fee21c9fdb65003377b0ef5c17ec54e8 100644 (file)
 
 namespace rocksdb {
 
+// This function may intentionally do a left shift on a -ve number
+#if defined(__clang__)
+__attribute__((__no_sanitize__("undefined")))
+#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
+__attribute__((__no_sanitize_undefined__))
+#endif
 uint32_t Hash(const char* data, size_t n, uint32_t seed) {
   // Similar to murmur hash
   const uint32_t m = 0xc6a4a793;
index fc5d6cdac7b5917a4279b7f7546f88c5553a8e48..f9098d4030c55359eb298fb0c4c73dcb909c3fce 100644 (file)
@@ -46,6 +46,11 @@ ColBufEncoder *ColBufEncoder::NewColBufEncoder(
   return nullptr;
 }
 
+#if defined(__clang__)
+__attribute__((__no_sanitize__("undefined")))
+#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
+__attribute__((__no_sanitize_undefined__))
+#endif
 size_t FixedLengthColBufEncoder::Append(const char *buf) {
   if (nullable_) {
     if (buf == nullptr) {