diff options
author | Evan Brown <ezb@google.com> | 2023-11-01 14:51:09 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-11-01 14:52:30 -0700 |
commit | 065d50d9f835cce8e4ee8f6d595518c409669901 (patch) | |
tree | cb71db40c8c61e9bf3f2389eddf09194aa468232 /absl/container/internal/raw_hash_set_test.cc | |
parent | f3760b4d3b2773d1cb8e9ddda29dc9bce386d540 (diff) |
Add sanitizer mode validation for use of references to swisstables elements that may have been invalidated by a container move.
PiperOrigin-RevId: 578649798
Change-Id: Icfee98d3a0399b545ec6ec59c5b52ae5e006218b
Diffstat (limited to 'absl/container/internal/raw_hash_set_test.cc')
-rw-r--r-- | absl/container/internal/raw_hash_set_test.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index 4e67b79e..4937e6fa 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -2375,10 +2375,17 @@ TEST(Iterator, InvalidUseWithMoveCrashesWithSanitizers) { IntTable t1, t2; t1.insert(1); auto it = t1.begin(); + // ptr will become invalidated on rehash. + const int64_t* ptr = &*it; + (void)ptr; + t2 = std::move(t1); EXPECT_DEATH_IF_SUPPORTED(*it, kInvalidIteratorDeathMessage); EXPECT_DEATH_IF_SUPPORTED(void(it == t2.begin()), kInvalidIteratorDeathMessage); +#ifdef ABSL_HAVE_ADDRESS_SANITIZER + EXPECT_DEATH_IF_SUPPORTED(std::cout << *ptr, "heap-use-after-free"); +#endif } TEST(Table, ReservedGrowthUpdatesWhenTableDoesntGrow) { |