aboutsummaryrefslogtreecommitdiff
path: root/absl/container/internal/container_memory.h
diff options
context:
space:
mode:
authorEvan Brown <ezb@google.com>2023-10-16 12:41:17 -0700
committerCopybara-Service <copybara-worker@google.com>2023-10-16 12:42:20 -0700
commit2a18ba753bca64e79f6d9857a9f64e638b32c371 (patch)
treed820433dcc72d326d85badd75b0f4e20d9bdca61 /absl/container/internal/container_memory.h
parentd368d3d64993b27f483a51de3d458b7cbdc2c544 (diff)
downloadabseil-2a18ba753bca64e79f6d9857a9f64e638b32c371.tar.gz
abseil-2a18ba753bca64e79f6d9857a9f64e638b32c371.tar.bz2
abseil-2a18ba753bca64e79f6d9857a9f64e638b32c371.zip
Add sanitizer mode checks that element constructors/destructors don't make reentrant calls to raw_hash_set member functions.
PiperOrigin-RevId: 573897598 Change-Id: If40c23ac3cd9fff315ee18774e27c480cbca3a81
Diffstat (limited to 'absl/container/internal/container_memory.h')
-rw-r--r--absl/container/internal/container_memory.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/absl/container/internal/container_memory.h b/absl/container/internal/container_memory.h
index f59ca4ee..a735ca34 100644
--- a/absl/container/internal/container_memory.h
+++ b/absl/container/internal/container_memory.h
@@ -249,6 +249,14 @@ inline void SanitizerUnpoisonObject(const T* object) {
SanitizerUnpoisonMemoryRegion(object, sizeof(T));
}
+template <typename Container, typename Alloc, typename F>
+void RunWithReentrancyGuard(Container& c, Alloc& a, F f) {
+ SanitizerPoisonObject(&c);
+ if (!std::is_empty<Alloc>()) SanitizerUnpoisonObject(&a);
+ f();
+ SanitizerUnpoisonObject(&c);
+}
+
namespace memory_internal {
// If Pair is a standard-layout type, OffsetOf<Pair>::kFirst and