Clang's unsigned integer overflow sanitizer is flagging BucketNumber as having an overflow. This seems to be intentional, and we should disable the sanitizer for this function.

PiperOrigin-RevId: 520968947
pull/12147/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 2a798b07ff
commit defe92a03c
  1. 3
      src/google/protobuf/map.h
  2. 6
      src/google/protobuf/port_def.inc

@ -1010,7 +1010,8 @@ class KeyMapBase : public UntypedMapBase {
}
template <typename K>
size_type BucketNumber(const K& k) const {
size_type PROTOBUF_NO_SANITIZE("unsigned-integer-overflow")
BucketNumber(const K& k) const {
// We xor the hash value against the random seed so that we effectively
// have a random hash function.
uint64_t h = hash_function()(k) ^ seed_;

@ -879,6 +879,12 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
#define PROTOBUF_UNUSED
#endif
#if __has_attribute(no_sanitize)
#define PROTOBUF_NO_SANITIZE(...) __attribute__((no_sanitize(__VA_ARGS__)))
#else
#define PROTOBUF_NO_SANITIZE(...)
#endif
// ThreadSafeArenaz is turned off completely in opensource builds.
// autoheader defines this in some circumstances

Loading…
Cancel
Save