[compiler-rt] 248ee65 - [scudo] Test ScudoReleaseTest.BufferPool with a buffer pool allocated on the heap
Chia-hung Duan via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 11:14:20 PDT 2023
Author: Fabio D'Urso
Date: 2023-03-16T18:13:43Z
New Revision: 248ee65ac647ac53a415aea1cf314e82f5a30075
URL: https://github.com/llvm/llvm-project/commit/248ee65ac647ac53a415aea1cf314e82f5a30075
DIFF: https://github.com/llvm/llvm-project/commit/248ee65ac647ac53a415aea1cf314e82f5a30075.diff
LOG: [scudo] Test ScudoReleaseTest.BufferPool with a buffer pool allocated on the heap
The previous code resulted in 252 KiB being allocated on the stack,
which caused a stack overflow on Fuchsia.
Reviewed By: Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D146229
Added:
Modified:
compiler-rt/lib/scudo/standalone/tests/release_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/tests/release_test.cpp b/compiler-rt/lib/scudo/standalone/tests/release_test.cpp
index 173928ead207e..1fc4284ca77fe 100644
--- a/compiler-rt/lib/scudo/standalone/tests/release_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/release_test.cpp
@@ -566,20 +566,25 @@ TEST(ScudoReleaseTest, ReleasePartialRegion) {
TEST(ScudoReleaseTest, BufferPool) {
constexpr scudo::uptr StaticBufferCount = SCUDO_WORDSIZE - 1;
constexpr scudo::uptr StaticBufferSize = 512U;
- scudo::BufferPool<StaticBufferCount, StaticBufferSize> Pool;
+
+ // Allocate the buffer pool on the heap because it is quite large (slightly
+ // more than StaticBufferCount * StaticBufferSize * sizeof(uptr)) and it may
+ // not fit in the stack on some platforms.
+ using BufferPool = scudo::BufferPool<StaticBufferCount, StaticBufferSize>;
+ std::unique_ptr<BufferPool> Pool(new BufferPool());
std::vector<std::pair<scudo::uptr *, scudo::uptr>> Buffers;
for (scudo::uptr I = 0; I < StaticBufferCount; ++I) {
- scudo::uptr *P = Pool.getBuffer(StaticBufferSize);
- EXPECT_TRUE(Pool.isStaticBufferTestOnly(P, StaticBufferSize));
+ scudo::uptr *P = Pool->getBuffer(StaticBufferSize);
+ EXPECT_TRUE(Pool->isStaticBufferTestOnly(P, StaticBufferSize));
Buffers.emplace_back(P, StaticBufferSize);
}
// The static buffer is supposed to be used up.
- scudo::uptr *P = Pool.getBuffer(StaticBufferSize);
- EXPECT_FALSE(Pool.isStaticBufferTestOnly(P, StaticBufferSize));
+ scudo::uptr *P = Pool->getBuffer(StaticBufferSize);
+ EXPECT_FALSE(Pool->isStaticBufferTestOnly(P, StaticBufferSize));
- Pool.releaseBuffer(P, StaticBufferSize);
+ Pool->releaseBuffer(P, StaticBufferSize);
for (auto &Buffer : Buffers)
- Pool.releaseBuffer(Buffer.first, Buffer.second);
+ Pool->releaseBuffer(Buffer.first, Buffer.second);
}
More information about the llvm-commits
mailing list