Index: compiler-rt/lib/asan/tests/asan_test.cpp =================================================================== --- compiler-rt/lib/asan/tests/asan_test.cpp +++ compiler-rt/lib/asan/tests/asan_test.cpp @@ -1161,11 +1161,9 @@ #if !defined(__ANDROID__) || __ANDROID_API__ >= 17 EXPECT_EQ(0, mlockall(MCL_CURRENT)); #endif - EXPECT_EQ(0, mlock((void*)0x12345, 0x5678)); #if !defined(__ANDROID__) || __ANDROID_API__ >= 17 EXPECT_EQ(0, munlockall()); #endif - EXPECT_EQ(0, munlock((void*)0x987, 0x654)); } #endif Index: compiler-rt/lib/msan/tests/msan_test.cpp =================================================================== --- compiler-rt/lib/msan/tests/msan_test.cpp +++ compiler-rt/lib/msan/tests/msan_test.cpp @@ -4666,9 +4666,7 @@ TEST(MemorySanitizer, MlockTest) { EXPECT_EQ(0, mlockall(MCL_CURRENT)); - EXPECT_EQ(0, mlock((void*)0x12345, 0x5678)); EXPECT_EQ(0, munlockall()); - EXPECT_EQ(0, munlock((void*)0x987, 0x654)); } // Test that LargeAllocator unpoisons memory before releasing it to the OS. Index: compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -6523,26 +6523,16 @@ #endif #if SANITIZER_INTERCEPT_MLOCKX -// Linux kernel has a bug that leads to kernel deadlock if a process -// maps TBs of memory and then calls mlock(). +// Sanitizers might map a large amount of unbacked memory. +// mlockall would exhaust all available system resources. static void MlockIsUnsupported() { static atomic_uint8_t printed; if (atomic_exchange(&printed, 1, memory_order_relaxed)) return; - VPrintf(1, "%s ignores mlock/mlockall/munlock/munlockall\n", + VPrintf(1, "%s ignores mlockall/munlockall\n", SanitizerToolName); } -INTERCEPTOR(int, mlock, const void *addr, uptr len) { - MlockIsUnsupported(); - return 0; -} - -INTERCEPTOR(int, munlock, const void *addr, uptr len) { - MlockIsUnsupported(); - return 0; -} - INTERCEPTOR(int, mlockall, int flags) { MlockIsUnsupported(); return 0; @@ -6554,8 +6544,6 @@ } #define INIT_MLOCKX \ - COMMON_INTERCEPT_FUNCTION(mlock); \ - COMMON_INTERCEPT_FUNCTION(munlock); \ COMMON_INTERCEPT_FUNCTION(mlockall); \ COMMON_INTERCEPT_FUNCTION(munlockall); Index: compiler-rt/test/sanitizer_common/TestCases/Linux/mlock_test.cpp =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Linux/mlock_test.cpp +++ compiler-rt/test/sanitizer_common/TestCases/Linux/mlock_test.cpp @@ -6,8 +6,6 @@ int main() { assert(0 == mlockall(MCL_CURRENT)); - assert(0 == mlock((void *)0x12345, 0x5678)); assert(0 == munlockall()); - assert(0 == munlock((void *)0x987, 0x654)); }