[llvm-commits] [compiler-rt] r171100 - in /compiler-rt/trunk/lib/msan: msan.cc msan_linux.cc

Evgeniy Stepanov eugeni.stepanov at gmail.com
Tue Dec 25 22:37:23 PST 2012


Author: eugenis
Date: Wed Dec 26 00:37:23 2012
New Revision: 171100

URL: http://llvm.org/viewvc/llvm-project?rev=171100&view=rev
Log:
[msan] Check for conflicting memory mappings.

Check for conflicting memory mappings before attempting to map shadow.
Helps avoid segfault on Linux with disabled ASLR.

Modified:
    compiler-rt/trunk/lib/msan/msan.cc
    compiler-rt/trunk/lib/msan/msan_linux.cc

Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Wed Dec 26 00:37:23 2012
@@ -240,8 +240,10 @@
   if (!InitShadow(/* prot1 */false, /* prot2 */true, /* map_shadow */true,
                   __msan_track_origins)) {
     // FIXME: prot1 = false is only required when running under DR.
-    Printf("FATAL: MemorySanitizer can not mmap the shadow memory\n");
+    Printf("FATAL: MemorySanitizer can not mmap the shadow memory.\n");
     Printf("FATAL: Make sure to compile with -fPIE and to link with -pie.\n");
+    Printf("FATAL: Disabling ASLR is known to cause this error.\n");
+    Printf("FATAL: If running under GDB, try 'set disable-randomization off'.\n");
     DumpProcessMap();
     Die();
   }

Modified: compiler-rt/trunk/lib/msan/msan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_linux.cc?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_linux.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_linux.cc Wed Dec 26 00:37:23 2012
@@ -51,6 +51,12 @@
     Printf("Bad1     : %p %p\n", kBad1Beg, kBad1End);
   }
 
+  if (!MemoryRangeIsAvailable(kShadowBeg,
+                              init_origins ? kOriginsEnd : kShadowEnd)) {
+    Printf("FATAL: Shadow memory range is not available.\n");
+    return false;
+  }
+
   if (prot1 && !Mprotect(kBad1Beg, kBad1End - kBad1Beg))
     return false;
   if (prot2 && !Mprotect(kBad2Beg, kBad2End - kBad2Beg))





More information about the llvm-commits mailing list