aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/memory.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/memory.h b/src/common/memory.h
index a4cad94c..03228f07 100644
--- a/src/common/memory.h
+++ b/src/common/memory.h
@@ -38,6 +38,10 @@
#include <memory>
#include <vector>
+#if defined(MEMORY_SANITIZER)
+#include <sanitizer/msan_interface.h>
+#endif
+
#ifdef __APPLE__
#define sys_mmap mmap
#define sys_mmap2 mmap
@@ -120,6 +124,12 @@ class PageAllocator {
if (a == MAP_FAILED)
return NULL;
+#if defined(MEMORY_SANITIZER)
+ // We need to indicate to MSan that memory allocated through sys_mmap is
+ // initialized, since linux_syscall_support.h doesn't have MSan hooks.
+ __msan_unpoison(a, page_size_ * num_pages);
+#endif
+
struct PageHeader *header = reinterpret_cast<PageHeader*>(a);
header->next = last_;
header->num_pages = num_pages;