From 02ebbf5991e18c57f633405c4b364c7b8db25503 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 17 Sep 2024 19:07:30 -0700 Subject: [PATCH] fix new/delete in sanitize-address test Summary: The use of `operator new` with sized `operator delete` in `folly/memory/test/SanitizeAddressTest.cpp` requires sized `operator delete`, which is not always available. Delegation to the correct `operator delete` is wrapped in `folly::operator_new` and `folly::operator_delete`, so switch to these. Reviewed By: ckwalsh Differential Revision: D62909014 fbshipit-source-id: ce223473cdfe61ccfa50ba85e15a569aa9b245ea --- folly/memory/test/BUCK | 1 + folly/memory/test/SanitizeAddressTest.cpp | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/folly/memory/test/BUCK b/folly/memory/test/BUCK index 089de5ffaa7..ee99d87e527 100644 --- a/folly/memory/test/BUCK +++ b/folly/memory/test/BUCK @@ -97,6 +97,7 @@ cpp_unittest( name = "sanitize_address_test", srcs = ["SanitizeAddressTest.cpp"], deps = [ + "//folly/lang:new", "//folly/memory:sanitize_address", "//folly/portability:gtest", ], diff --git a/folly/memory/test/SanitizeAddressTest.cpp b/folly/memory/test/SanitizeAddressTest.cpp index b75242a0de0..456184942b1 100644 --- a/folly/memory/test/SanitizeAddressTest.cpp +++ b/folly/memory/test/SanitizeAddressTest.cpp @@ -16,8 +16,7 @@ #include -#include - +#include #include class SanitizeAddressTest : public testing::Test {}; @@ -31,7 +30,7 @@ TEST_F(SanitizeAddressTest, asan_poison) { // malloc auto const addr = - static_cast(operator new(size, std::align_val_t{page})); + static_cast(folly::operator_new(size, std::align_val_t{page})); EXPECT_EQ(nullptr, folly::asan_region_is_poisoned(addr, size)); EXPECT_EQ(0, folly::asan_address_is_poisoned(addr + offs)); @@ -58,7 +57,7 @@ TEST_F(SanitizeAddressTest, asan_poison) { // free - operator delete(addr, size, std::align_val_t{page}); + folly::operator_delete(addr, size, std::align_val_t{page}); EXPECT_EQ( folly::kIsSanitizeAddress ? addr : nullptr, folly::asan_region_is_poisoned(addr, size));