Skip to content

Commit bddd8ea

Browse files
committed
Revert "[scudo] Apply filling when realloc shrinks and re-grows a block in-place (llvm#93212)"
This reverts commit 760d880. It broke https://lab.llvm.org/buildbot/#/builders/169/builds/32309
1 parent bc022b4 commit bddd8ea

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

compiler-rt/lib/scudo/standalone/combined.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -565,20 +565,6 @@ class Allocator {
565565
storeSecondaryAllocationStackMaybe(Options, OldPtr, NewSize);
566566
}
567567
}
568-
569-
// If we have reduced the size, set the extra bytes to the fill value
570-
// so that we are ready to grow it again in the future.
571-
if (NewSize < OldSize) {
572-
const FillContentsMode FillContents =
573-
TSDRegistry.getDisableMemInit() ? NoFill
574-
: Options.getFillContentsMode();
575-
if (FillContents != NoFill) {
576-
memset(reinterpret_cast<char *>(OldTaggedPtr) + NewSize,
577-
FillContents == ZeroFill ? 0 : PatternFillByte,
578-
OldSize - NewSize);
579-
}
580-
}
581-
582568
return OldTaggedPtr;
583569
}
584570
}

compiler-rt/lib/scudo/standalone/tests/combined_test.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -447,32 +447,19 @@ SCUDO_TYPED_TEST(ScudoCombinedDeathTest, ReallocateSame) {
447447
// returns the same chunk. This requires that all the sizes we iterate on use
448448
// the same block size, but that should be the case for MaxSize - 64 with our
449449
// default class size maps.
450-
constexpr scudo::uptr InitialSize =
450+
constexpr scudo::uptr ReallocSize =
451451
TypeParam::Primary::SizeClassMap::MaxSize - 64;
452+
void *P = Allocator->allocate(ReallocSize, Origin);
452453
const char Marker = 'A';
453-
Allocator->setFillContents(scudo::PatternOrZeroFill);
454-
455-
void *P = Allocator->allocate(InitialSize, Origin);
456-
scudo::uptr CurrentSize = InitialSize;
454+
memset(P, Marker, ReallocSize);
457455
for (scudo::sptr Delta = -32; Delta < 32; Delta += 8) {
458-
memset(P, Marker, CurrentSize);
459456
const scudo::uptr NewSize =
460-
static_cast<scudo::uptr>(static_cast<scudo::sptr>(InitialSize) + Delta);
457+
static_cast<scudo::uptr>(static_cast<scudo::sptr>(ReallocSize) + Delta);
461458
void *NewP = Allocator->reallocate(P, NewSize);
462459
EXPECT_EQ(NewP, P);
463-
464-
// Verify that existing contents have been preserved.
465-
for (scudo::uptr I = 0; I < scudo::Min(CurrentSize, NewSize); I++)
460+
for (scudo::uptr I = 0; I < ReallocSize - 32; I++)
466461
EXPECT_EQ((reinterpret_cast<char *>(NewP))[I], Marker);
467-
468-
// Verify that new bytes are set according to FillContentsMode.
469-
for (scudo::uptr I = CurrentSize; I < NewSize; I++) {
470-
EXPECT_EQ((reinterpret_cast<unsigned char *>(NewP))[I],
471-
scudo::PatternFillByte);
472-
}
473-
474462
checkMemoryTaggingMaybe(Allocator, NewP, NewSize, 0);
475-
CurrentSize = NewSize;
476463
}
477464
Allocator->deallocate(P, Origin);
478465
}

0 commit comments

Comments
 (0)