[compiler-rt] r193755 - [msan] Disable mlock/mlockall to work around a linux kernel bug.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Oct 31 08:51:22 PDT 2013
Author: eugenis
Date: Thu Oct 31 10:51:22 2013
New Revision: 193755
URL: http://llvm.org/viewvc/llvm-project?rev=193755&view=rev
Log:
[msan] Disable mlock/mlockall to work around a linux kernel bug.
The same logic is present in ASan and TSan.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=193755&r1=193754&r2=193755&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Thu Oct 31 10:51:22 2013
@@ -1172,6 +1172,35 @@ INTERCEPTOR(void *, shmat, int shmid, co
return p;
}
+// Linux kernel has a bug that leads to kernel deadlock if a process
+// maps TBs of memory and then calls mlock().
+static void MlockIsUnsupported() {
+ static atomic_uint8_t printed;
+ if (atomic_exchange(&printed, 1, memory_order_relaxed))
+ return;
+ if (common_flags()->verbosity > 0)
+ Printf("INFO: MemorySanitizer ignores mlock/mlockall/munlock/munlockall\n");
+}
+
+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;
+}
+
+INTERCEPTOR(int, munlockall, void) {
+ MlockIsUnsupported();
+ return 0;
+}
struct MSanInterceptorContext {
bool in_interceptor_scope;
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=193755&r1=193754&r2=193755&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Thu Oct 31 10:51:22 2013
@@ -3496,3 +3496,10 @@ TEST(MemorySanitizerAllocator, get_alloc
delete int_ptr;
}
+
+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));
+}
More information about the llvm-commits
mailing list