[scudo] Regression test for the MTE crash in storeEndMarker.
The original problem was fixed in D105261.
Differential Revision: https://reviews.llvm.org/D114022
GitOrigin-RevId: 913d78c40c37c9c3428285d868ce454b058e40f3
diff --git a/lib/scudo/standalone/tests/combined_test.cpp b/lib/scudo/standalone/tests/combined_test.cpp
index a2461c5..deccccf 100644
--- a/lib/scudo/standalone/tests/combined_test.cpp
+++ b/lib/scudo/standalone/tests/combined_test.cpp
@@ -679,3 +679,23 @@
Allocator->setOption(scudo::Option::ThreadDisableMemInit, 0);
}
+
+SCUDO_TYPED_TEST(ScudoCombinedTest, ReallocateInPlaceStress) {
+ auto *Allocator = this->Allocator.get();
+
+ // Regression test: make realloc-in-place happen at the very right end of a
+ // mapped region.
+ constexpr int nPtrs = 10000;
+ for (int i = 1; i < 32; ++i) {
+ scudo::uptr Size = 16 * i - 1;
+ std::vector<void *> Ptrs;
+ for (int i = 0; i < nPtrs; ++i) {
+ void *P = Allocator->allocate(Size, Origin);
+ P = Allocator->reallocate(P, Size + 1);
+ Ptrs.push_back(P);
+ }
+
+ for (int i = 0; i < nPtrs; ++i)
+ Allocator->deallocate(Ptrs[i], Origin);
+ }
+}