From 5263da639644ecc9b5c6b098ed0853d405c1151d Mon Sep 17 00:00:00 2001 From: Igor Sugak Date: Tue, 20 Feb 2018 16:41:54 -0800 Subject: [PATCH] fix shift UBSAN error in col_buf_encoder.cc Summary: Add a static cast to perform the left shift as with an unsigned type. make ubsan_check Closes https://github.com/facebook/rocksdb/pull/3517 Reviewed By: sagar0 Differential Revision: D7016044 Pulled By: igorsugak fbshipit-source-id: baf72f6197edd8f7220d010b15a23d6de6a72c49 --- utilities/col_buf_encoder.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/utilities/col_buf_encoder.cc b/utilities/col_buf_encoder.cc index feaf5646a..f8b19e8c7 100644 --- a/utilities/col_buf_encoder.cc +++ b/utilities/col_buf_encoder.cc @@ -46,13 +46,6 @@ ColBufEncoder *ColBufEncoder::NewColBufEncoder( return nullptr; } -#ifdef ROCKSDB_UBSAN_RUN -#if defined(__clang__) -__attribute__((__no_sanitize__("shift"))) -#elif defined(__GNUC__) -__attribute__((__no_sanitize_undefined__)) -#endif -#endif size_t FixedLengthColBufEncoder::Append(const char *buf) { if (nullable_) { if (buf == nullptr) { @@ -72,7 +65,7 @@ size_t FixedLengthColBufEncoder::Append(const char *buf) { col_compression_type_ == kColRleDeltaVarint) { int64_t delta = read_val - last_val_; // Encode signed delta value - delta = (delta << 1) ^ (delta >> 63); + delta = (static_cast(delta) << 1) ^ (delta >> 63); write_val = delta; last_val_ = read_val; } else if (col_compression_type_ == kColDict ||