[compiler-rt] r193755 - [msan] Disable mlock/mlockall to work around a linux kernel bug.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Oct 31 09:52:23 PDT 2013


Of course we should!
I'll try not to forget to do this later this week.


On Thu, Oct 31, 2013 at 9:01 AM, Dmitry Vyukov <dvyukov at google.com> wrote:
> On Thu, Oct 31, 2013 at 7:51 PM, Evgeniy Stepanov
> <eugeni.stepanov at gmail.com> wrote:
>> 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) {
>
> Probably we should move this in sanitizer_common
>
>
>> +  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));
>> +}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list