[compiler-rt] [scudo] Apply filling option when realloc grows a block in-place too (PR #93212)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 10:21:41 PDT 2024


================
@@ -374,7 +384,18 @@ SCUDO_TYPED_TEST(ScudoCombinedTest, PatternOrZeroFill) {
         else
           ASSERT_TRUE(V == scudo::PatternFillByte || V == 0);
       }
+
+      // Fill with a known pattern different from PatternFillByte.
       memset(P, 0xaa, Size);
+
+      // Shrink and then grow by one byte, verifying that it gets re-filled in
+      // the process. We assume that changing the size by just 1 is done in
+      // place.
+      ASSERT_EQ(Allocator->reallocate(P, Size - 1), P);
+      ASSERT_EQ(Allocator->reallocate(P, Size), P);
+      EXPECT_EQ((reinterpret_cast<unsigned char *>(P))[Size - 1],
+                scudo::PatternFillByte);
+
----------------
ChiaHungDuan wrote:

I think we shouldn't make the assumption that "changing the size by just 1 is done in place" in the test. 

Given that this has no immediate impact and is not harmful if we don't test it. I think it's fine to leave it untested.

https://github.com/llvm/llvm-project/pull/93212


More information about the llvm-commits mailing list