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 #include +#if defined(MEMORY_SANITIZER) +#include +#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(a); header->next = last_; header->num_pages = num_pages;