[compiler-rt] [scudo] Skip test if mlock fails. (PR #168448)
Christopher Ferris via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 17 13:49:40 PST 2025
https://github.com/cferris1000 created https://github.com/llvm/llvm-project/pull/168448
Some linux versions might not support the mlock call, so skip that part of the test if the mlock fails.
>From 45dadb4c89dd8e56f506f9b1be58b59edc39939e Mon Sep 17 00:00:00 2001
From: Christopher Ferris <cferris at google.com>
Date: Mon, 17 Nov 2025 13:43:55 -0800
Subject: [PATCH] [scudo] Skip test if mlock fails.
Some linux versions might not support the mlock call, so skip that
part of the test if the mlock fails.
---
.../lib/scudo/standalone/tests/map_test.cpp | 22 +++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/compiler-rt/lib/scudo/standalone/tests/map_test.cpp b/compiler-rt/lib/scudo/standalone/tests/map_test.cpp
index afdfe5be85fb6..9d1a35c44679d 100644
--- a/compiler-rt/lib/scudo/standalone/tests/map_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/map_test.cpp
@@ -120,17 +120,17 @@ TEST(ScudoMapTest, Zeroing) {
#if SCUDO_LINUX
// Now verify that if madvise fails, the data is still zeroed.
memset(Data, 1U, MemMap.getCapacity());
- EXPECT_NE(-1, mlock(Data, MemMap.getCapacity()));
-
- EXPECT_EQ(1U, Data[0]);
- EXPECT_EQ(1U, Data[PageSize]);
- EXPECT_EQ(1U, Data[PageSize * 2]);
- MemMap.releaseAndZeroPagesToOS(MemMap.getBase(), MemMap.getCapacity());
- EXPECT_EQ(0U, Data[0]);
- EXPECT_EQ(0U, Data[PageSize]);
- EXPECT_EQ(0U, Data[PageSize * 2]);
-
- EXPECT_NE(-1, munlock(Data, MemMap.getCapacity()));
+ if (mlock(Data, MemMap.getCapacity()) != -1) {
+ EXPECT_EQ(1U, Data[0]);
+ EXPECT_EQ(1U, Data[PageSize]);
+ EXPECT_EQ(1U, Data[PageSize * 2]);
+ MemMap.releaseAndZeroPagesToOS(MemMap.getBase(), MemMap.getCapacity());
+ EXPECT_EQ(0U, Data[0]);
+ EXPECT_EQ(0U, Data[PageSize]);
+ EXPECT_EQ(0U, Data[PageSize * 2]);
+
+ EXPECT_NE(-1, munlock(Data, MemMap.getCapacity()));
+ }
#endif
MemMap.unmap();
More information about the llvm-commits
mailing list