aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio D'Urso <fdurso@google.com>2024-06-10 13:33:11 +0200
committerFabio D'Urso <fdurso@google.com>2024-06-10 13:35:42 +0200
commitbddd8eae17df6511aee789744ccdc158de817081 (patch)
treea18401a3793493eca42f174d6c2c52604b00e1c9
parentbc022b406d094d3c7b6d04c97b8bcf3109c6d74e (diff)
downloadllvm-bddd8eae17df6511aee789744ccdc158de817081.zip
llvm-bddd8eae17df6511aee789744ccdc158de817081.tar.gz
llvm-bddd8eae17df6511aee789744ccdc158de817081.tar.bz2
Revert "[scudo] Apply filling when realloc shrinks and re-grows a block in-place (#93212)"
This reverts commit 760d880ea602117aa2e6bba4cf31069f09225b4b. It broke https://lab.llvm.org/buildbot/#/builders/169/builds/32309
-rw-r--r--compiler-rt/lib/scudo/standalone/combined.h14
-rw-r--r--compiler-rt/lib/scudo/standalone/tests/combined_test.cpp23
2 files changed, 5 insertions, 32 deletions
diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index 73da686..f9ed365 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -565,20 +565,6 @@ public:
storeSecondaryAllocationStackMaybe(Options, OldPtr, NewSize);
}
}
-
- // If we have reduced the size, set the extra bytes to the fill value
- // so that we are ready to grow it again in the future.
- if (NewSize < OldSize) {
- const FillContentsMode FillContents =
- TSDRegistry.getDisableMemInit() ? NoFill
- : Options.getFillContentsMode();
- if (FillContents != NoFill) {
- memset(reinterpret_cast<char *>(OldTaggedPtr) + NewSize,
- FillContents == ZeroFill ? 0 : PatternFillByte,
- OldSize - NewSize);
- }
- }
-
return OldTaggedPtr;
}
}
diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
index 655dc87..1a36155 100644
--- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
@@ -447,32 +447,19 @@ SCUDO_TYPED_TEST(ScudoCombinedDeathTest, ReallocateSame) {
// returns the same chunk. This requires that all the sizes we iterate on use
// the same block size, but that should be the case for MaxSize - 64 with our
// default class size maps.
- constexpr scudo::uptr InitialSize =
+ constexpr scudo::uptr ReallocSize =
TypeParam::Primary::SizeClassMap::MaxSize - 64;
+ void *P = Allocator->allocate(ReallocSize, Origin);
const char Marker = 'A';
- Allocator->setFillContents(scudo::PatternOrZeroFill);
-
- void *P = Allocator->allocate(InitialSize, Origin);
- scudo::uptr CurrentSize = InitialSize;
+ memset(P, Marker, ReallocSize);
for (scudo::sptr Delta = -32; Delta < 32; Delta += 8) {
- memset(P, Marker, CurrentSize);
const scudo::uptr NewSize =
- static_cast<scudo::uptr>(static_cast<scudo::sptr>(InitialSize) + Delta);
+ static_cast<scudo::uptr>(static_cast<scudo::sptr>(ReallocSize) + Delta);
void *NewP = Allocator->reallocate(P, NewSize);
EXPECT_EQ(NewP, P);
-
- // Verify that existing contents have been preserved.
- for (scudo::uptr I = 0; I < scudo::Min(CurrentSize, NewSize); I++)
+ for (scudo::uptr I = 0; I < ReallocSize - 32; I++)
EXPECT_EQ((reinterpret_cast<char *>(NewP))[I], Marker);
-
- // Verify that new bytes are set according to FillContentsMode.
- for (scudo::uptr I = CurrentSize; I < NewSize; I++) {
- EXPECT_EQ((reinterpret_cast<unsigned char *>(NewP))[I],
- scudo::PatternFillByte);
- }
-
checkMemoryTaggingMaybe(Allocator, NewP, NewSize, 0);
- CurrentSize = NewSize;
}
Allocator->deallocate(P, Origin);
}