diff options
author | Abseil Team <absl-team@google.com> | 2024-01-11 11:44:12 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-01-11 11:44:55 -0800 |
commit | 3acbe29b14428820cd18857284e082ac9926e314 (patch) | |
tree | 6ceab7b9e57019ccb1038f7064af1ccd65664fad /absl/container/internal | |
parent | a00f6d6d0ce50fbae36e639a58b1a8b78d09064c (diff) | |
download | abseil-3acbe29b14428820cd18857284e082ac9926e314.tar.gz abseil-3acbe29b14428820cd18857284e082ac9926e314.tar.bz2 abseil-3acbe29b14428820cd18857284e082ac9926e314.zip |
Enable ABSL_BTREE_ENABLE_GENERATIONS and ABSL_SWISSTABLE_ENABLE_GENERATIONS with ABSL_HAVE_HWADDRESS_SANITIZER.
It will detect bugs similar to Asan.
Also updated related tests to pass with HWASAN.
They are still flaky because of nature of HWASAN algorithm,
but test can be update to avoid flakiness, which I will do
in followup patches.
PiperOrigin-RevId: 597613798
Change-Id: Ic8af36a268ca041c002eb561b946aa2d9b93996a
Diffstat (limited to 'absl/container/internal')
-rw-r--r-- | absl/container/internal/btree.h | 4 | ||||
-rw-r--r-- | absl/container/internal/raw_hash_set.h | 1 | ||||
-rw-r--r-- | absl/container/internal/raw_hash_set_test.cc | 6 |
3 files changed, 7 insertions, 4 deletions
diff --git a/absl/container/internal/btree.h b/absl/container/internal/btree.h index 3526471d..91df57a3 100644 --- a/absl/container/internal/btree.h +++ b/absl/container/internal/btree.h @@ -79,6 +79,7 @@ namespace container_internal { #ifdef ABSL_BTREE_ENABLE_GENERATIONS #error ABSL_BTREE_ENABLE_GENERATIONS cannot be directly set #elif defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ + defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \ defined(ABSL_HAVE_MEMORY_SANITIZER) // When compiled in sanitizer mode, we add generation integers to the nodes and // iterators. When iterators are used, we validate that the container has not @@ -2856,7 +2857,8 @@ inline auto btree<P>::internal_emplace(iterator iter, Args &&...args) } } (void)replaced_node; -#ifdef ABSL_HAVE_ADDRESS_SANITIZER +#if defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ + defined(ABSL_HAVE_HWADDRESS_SANITIZER) if (!replaced_node) { assert(iter.node_->is_leaf()); if (iter.node_->is_root()) { diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index 9c65984d..b6dc7548 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -234,6 +234,7 @@ namespace container_internal { #ifdef ABSL_SWISSTABLE_ENABLE_GENERATIONS #error ABSL_SWISSTABLE_ENABLE_GENERATIONS cannot be directly set #elif defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ + defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \ defined(ABSL_HAVE_MEMORY_SANITIZER) // When compiled in sanitizer mode, we add generation integers to the backing // array and iterators. In the backing array, we store the generation between diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index fe000742..f9797f56 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -2218,10 +2218,10 @@ TEST(TableDeathTest, InvalidIteratorAsserts) { EXPECT_DEATH_IF_SUPPORTED(++iter, kErasedDeathMessage); } -// Invalid iterator use can trigger heap-use-after-free in asan, +// Invalid iterator use can trigger use-after-free in asan/hwasan, // use-of-uninitialized-value in msan, or invalidated iterator assertions. constexpr const char* kInvalidIteratorDeathMessage = - "heap-use-after-free|use-of-uninitialized-value|invalidated " + "use-after-free|use-of-uninitialized-value|invalidated " "iterator|Invalid iterator|invalid iterator"; // MSVC doesn't support | in regex. @@ -2579,7 +2579,7 @@ TEST(Table, InvalidReferenceUseCrashesWithSanitizers) { // ptr will become invalidated on rehash. const int64_t* ptr = &*t.begin(); t.insert(++i); - EXPECT_DEATH_IF_SUPPORTED(std::cout << *ptr, "heap-use-after-free") << i; + EXPECT_DEATH_IF_SUPPORTED(std::cout << *ptr, "use-after-free") << i; } } |