[compiler-rt] 261d9e5 - [scudo] Fix MallocIterateBoundary test on 32 bit Android.
Christopher Ferris via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 14 10:35:53 PDT 2023
Author: Christopher Ferris
Date: 2023-06-14T10:35:41-07:00
New Revision: 261d9e58d42efe4cfc34c5dd16b3001e4ffd39d6
URL: https://github.com/llvm/llvm-project/commit/261d9e58d42efe4cfc34c5dd16b3001e4ffd39d6
DIFF: https://github.com/llvm/llvm-project/commit/261d9e58d42efe4cfc34c5dd16b3001e4ffd39d6.diff
LOG: [scudo] Fix MallocIterateBoundary test on 32 bit Android.
On Android, the min alignment is 16 bytes. This test needs
the BlockDelta to match the min alignment, so set this value
differently for Android.
Update the comment in to explain these details.
Reviewed By: Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D152884
Added:
Modified:
compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
index 05d1d4826bd55..ebf66e1c92e7c 100644
--- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -333,11 +333,20 @@ static void callback(uintptr_t Base, size_t Size, void *Arg) {
// block is a boundary for. It must only be seen once by the callback function.
TEST(ScudoWrappersCTest, MallocIterateBoundary) {
const size_t PageSize = sysconf(_SC_PAGESIZE);
+#if SCUDO_ANDROID
+ // Android uses a 16 byte alignment for both 32 bit and 64 bit.
+ const size_t BlockDelta = 16U;
+#else
const size_t BlockDelta = FIRST_32_SECOND_64(8U, 16U);
+#endif
const size_t SpecialSize = PageSize - BlockDelta;
// We aren't guaranteed that any size class is exactly a page wide. So we need
- // to keep making allocations until we succeed.
+ // to keep making allocations until we get an allocation that starts exactly
+ // on a page boundary. The BlockDelta value is expected to be the number of
+ // bytes to subtract from a returned pointer to get to the actual start of
+ // the pointer in the size class. In practice, this means BlockDelta should
+ // be set to the minimum alignment in bytes for the allocation.
//
// With a 16-byte block alignment and 4096-byte page size, each allocation has
// a probability of (1 - (16/4096)) of failing to meet the alignment
More information about the llvm-commits
mailing list