diff options
author | 2023-02-10 06:31:03 -0800 | |
---|---|---|
committer | 2023-02-10 06:31:53 -0800 | |
commit | cde2f0eaaed3fb8581511cb5719d39172a5a2d81 (patch) | |
tree | 5e1bd18df537626cb1adf6f4a811c643c2ea342e /absl/container | |
parent | fa4855403cdfb91b9c16f792041258ed819594c1 (diff) |
Workaround MSan false positive.
On Linux Kernels >= 5.4 MSan reports a false positive when accessing thread local storage data from loaded libraries.
This was reported on Chromium (which on some build configurations uses absl as a dynamic library). More info here: crbug.com/1414573.
PiperOrigin-RevId: 508645053
Change-Id: I5d5a97e1ee7230cc23f3934a4ec5594b883918b4
Diffstat (limited to 'absl/container')
-rw-r--r-- | absl/container/BUILD.bazel | 1 | ||||
-rw-r--r-- | absl/container/CMakeLists.txt | 1 | ||||
-rw-r--r-- | absl/container/internal/raw_hash_set.cc | 6 |
3 files changed, 8 insertions, 0 deletions
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 96963c4b..038e5234 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -622,6 +622,7 @@ cc_library( ":hashtablez_sampler", "//absl/base:config", "//absl/base:core_headers", + "//absl/base:dynamic_annotations", "//absl/base:endian", "//absl/base:prefetch", "//absl/base:raw_logging_internal", diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt index 9ba95b32..43d60b9d 100644 --- a/absl/container/CMakeLists.txt +++ b/absl/container/CMakeLists.txt @@ -706,6 +706,7 @@ absl_cc_library( absl::container_common absl::container_memory absl::core_headers + absl::dynamic_annotations absl::endian absl::hash absl::hash_policy_traits diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc index 5dc8b2fa..a6d9b7c0 100644 --- a/absl/container/internal/raw_hash_set.cc +++ b/absl/container/internal/raw_hash_set.cc @@ -19,6 +19,7 @@ #include <cstring> #include "absl/base/config.h" +#include "absl/base/dynamic_annotations.h" #include "absl/hash/hash.h" namespace absl { @@ -44,6 +45,11 @@ constexpr size_t Group::kWidth; inline size_t RandomSeed() { #ifdef ABSL_HAVE_THREAD_LOCAL static thread_local size_t counter = 0; + // On Linux kernels >= 5.4 the MSAN runtime has a false-positive when + // accessing thread local storage data from loaded libraries + // (https://github.com/google/sanitizers/issues/1265), for this reason counter + // needs to be annotated as initialized. + ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(&counter, sizeof(size_t)); size_t value = ++counter; #else // ABSL_HAVE_THREAD_LOCAL static std::atomic<size_t> counter(0); |