diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp index 5c5f646538bbb5..5db249d0a85ad6 100644 --- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,14 @@ template struct TestAllocator : scudo::Allocator { this->disableMemoryTagging(); } ~TestAllocator() { this->unmapTestOnly(); } + + void *operator new(size_t size) { + void *p = nullptr; + EXPECT_EQ(0, posix_memalign(&p, alignof(TestAllocator), size)); + return p; + } + + void operator delete(void *ptr) { free(ptr); } }; template struct ScudoCombinedTest : public Test { diff --git a/compiler-rt/lib/scudo/standalone/tests/primary_test.cpp b/compiler-rt/lib/scudo/standalone/tests/primary_test.cpp index d90b6a34c0bcf5..e7aa6f795b66cd 100644 --- a/compiler-rt/lib/scudo/standalone/tests/primary_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/primary_test.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -63,6 +64,14 @@ struct SizeClassAllocator template struct TestAllocator : public SizeClassAllocator { ~TestAllocator() { this->unmapTestOnly(); } + + void *operator new(size_t size) { + void *p = nullptr; + EXPECT_EQ(0, posix_memalign(&p, alignof(TestAllocator), size)); + return p; + } + + void operator delete(void *ptr) { free(ptr); } }; template struct ScudoPrimaryTest : public Test {};