[llvm-commits] [compiler-rt] r158143 - in /compiler-rt/trunk/lib/asan: asan_allocator.cc asan_rtl.cc

Kostya Serebryany kcc at google.com
Thu Jun 7 02:15:48 PDT 2012


Author: kcc
Date: Thu Jun  7 04:15:48 2012
New Revision: 158143

URL: http://llvm.org/viewvc/llvm-project?rev=158143&view=rev
Log:
[asan] slow 16-byte redzones (still experimental)

Modified:
    compiler-rt/trunk/lib/asan/asan_allocator.cc
    compiler-rt/trunk/lib/asan/asan_rtl.cc

Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=158143&r1=158142&r2=158143&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Thu Jun  7 04:15:48 2012
@@ -174,29 +174,27 @@
   // Typically the beginning of the user-accessible memory is 'this'+REDZONE
   // and is also aligned by REDZONE. However, if the memory is allocated
   // by memalign, the alignment might be higher and the user-accessible memory
-  // starts at the first properly aligned address after the end of 'this'.
-  uptr   Beg() {
-    return RoundUpTo((uptr)this + sizeof(ChunkBase), 1 << alignment_log);
-  }
+  // starts at the first properly aligned address after 'this'.
+  uptr Beg() { return RoundUpTo((uptr)this + 1, 1 << alignment_log); }
   uptr Size() { return SizeClassToSize(size_class); }
   u8 SizeClass() { return size_class; }
 };
 
 struct AsanChunk: public ChunkBase {
   u32 *compressed_alloc_stack() {
-    CHECK(REDZONE >= sizeof(ChunkBase));
     return (u32*)((uptr)this + sizeof(ChunkBase));
   }
   u32 *compressed_free_stack() {
-    CHECK(REDZONE >= sizeof(ChunkBase));
-    return (u32*)((uptr)this + REDZONE);
+    return (u32*)((uptr)this + Max(REDZONE, (uptr)sizeof(ChunkBase)));
   }
 
   // The left redzone after the ChunkBase is given to the alloc stack trace.
   uptr compressed_alloc_stack_size() {
+    if (REDZONE < sizeof(ChunkBase)) return 0;
     return (REDZONE - sizeof(ChunkBase)) / sizeof(u32);
   }
   uptr compressed_free_stack_size() {
+    if (REDZONE < sizeof(ChunkBase)) return 0;
     return (REDZONE) / sizeof(u32);
   }
 
@@ -680,7 +678,7 @@
   m->next = 0;
   CHECK(m->Size() == size_to_allocate);
   uptr addr = (uptr)m + REDZONE;
-  CHECK(addr == (uptr)m->compressed_free_stack());
+  CHECK(addr <= (uptr)m->compressed_free_stack());
 
   if (alignment > REDZONE && (addr & (alignment - 1))) {
     addr = RoundUpTo(addr, alignment);

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=158143&r1=158142&r2=158143&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Jun  7 04:15:48 2012
@@ -445,8 +445,8 @@
   IntFlagValue(options, "verbosity=", &FLAG_v);
 
   IntFlagValue(options, "redzone=", (s64*)&FLAG_redzone);
-  CHECK(FLAG_redzone >= 32);
-  CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0);
+  CHECK(FLAG_redzone >= 16);
+  CHECK(IsPowerOfTwo(FLAG_redzone));
   IntFlagValue(options, "quarantine_size=", (s64*)&FLAG_quarantine_size);
 
   IntFlagValue(options, "atexit=", &FLAG_atexit);





More information about the llvm-commits mailing list