[compiler-rt] r214299 - [asan] rename new-delete-size-mismatch to new-delete-type-mismatch and make the report more verbose

Kostya Serebryany kcc at google.com
Wed Jul 30 04:20:38 PDT 2014


Author: kcc
Date: Wed Jul 30 06:20:37 2014
New Revision: 214299

URL: http://llvm.org/viewvc/llvm-project?rev=214299&view=rev
Log:
[asan] rename new-delete-size-mismatch to new-delete-type-mismatch and make the report more verbose

Modified:
    compiler-rt/trunk/lib/asan/asan_allocator2.cc
    compiler-rt/trunk/lib/asan/asan_flags.h
    compiler-rt/trunk/lib/asan/asan_report.cc
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/test/asan/TestCases/Linux/sized_delete_test.cc

Modified: compiler-rt/trunk/lib/asan/asan_allocator2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator2.cc?rev=214299&r1=214298&r2=214299&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator2.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator2.cc Wed Jul 30 06:20:37 2014
@@ -454,7 +454,7 @@ static void Deallocate(void *ptr, uptr d
 
   uptr chunk_beg = p - kChunkHeaderSize;
   AsanChunk *m = reinterpret_cast<AsanChunk *>(chunk_beg);
-  if (delete_size && flags()->new_delete_size_mismatch &&
+  if (delete_size && flags()->new_delete_type_mismatch &&
       delete_size != m->UsedSize()) {
     ReportNewDeleteSizeMismatch(p, delete_size, stack);
   }

Modified: compiler-rt/trunk/lib/asan/asan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_flags.h?rev=214299&r1=214298&r2=214299&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.h (original)
+++ compiler-rt/trunk/lib/asan/asan_flags.h Wed Jul 30 06:20:37 2014
@@ -58,7 +58,7 @@ struct Flags {
   bool poison_heap;
   bool poison_partial;
   bool alloc_dealloc_mismatch;
-  bool new_delete_size_mismatch;
+  bool new_delete_type_mismatch;
   bool strict_memcmp;
   bool strict_init_order;
   bool start_deactivated;

Modified: compiler-rt/trunk/lib/asan/asan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=214299&r1=214298&r2=214299&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_report.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_report.cc Wed Jul 30 06:20:37 2014
@@ -659,19 +659,21 @@ void ReportNewDeleteSizeMismatch(uptr ad
   Printf("%s", d.Warning());
   char tname[128];
   u32 curr_tid = GetCurrentTidOrInvalid();
-  Report("ERROR: AddressSanitizer: new-delete-size-mismatch on %p in "
+  Report("ERROR: AddressSanitizer: new-delete-type-mismatch on %p in "
          "thread T%d%s:\n",
          addr, curr_tid,
          ThreadNameWithParenthesis(curr_tid, tname, sizeof(tname)));
-  Printf("%s  sized operator delete called with size %zd\n", d.EndWarning(),
-         delete_size);
+  Printf("%s  object passed to delete has wrong type:\n", d.EndWarning());
+  Printf("  size of the allocated type:   %zd bytes;\n"
+         "  size of the deallocated type: %zd bytes.\n",
+         asan_mz_size(reinterpret_cast<void*>(addr)), delete_size);
   CHECK_GT(free_stack->size, 0);
   GET_STACK_TRACE_FATAL(free_stack->trace[0], free_stack->top_frame_bp);
   stack.Print();
   DescribeHeapAddress(addr, 1);
-  ReportErrorSummary("new-delete-size-mismatch", &stack);
+  ReportErrorSummary("new-delete-type-mismatch", &stack);
   Report("HINT: if you don't care about these warnings you may set "
-         "ASAN_OPTIONS=new_delete_size_mismatch=0\n");
+         "ASAN_OPTIONS=new_delete_type_mismatch=0\n");
 }
 
 void ReportFreeNotMalloced(uptr addr, StackTrace *free_stack) {

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=214299&r1=214298&r2=214299&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Jul 30 06:20:37 2014
@@ -199,7 +199,7 @@ static void ParseFlagsFromString(Flags *
   ParseFlag(str, &f->alloc_dealloc_mismatch, "alloc_dealloc_mismatch",
       "Report errors on malloc/delete, new/free, new/delete[], etc.");
 
-  ParseFlag(str, &f->new_delete_size_mismatch, "new_delete_size_mismatch",
+  ParseFlag(str, &f->new_delete_type_mismatch, "new_delete_type_mismatch",
       "Report errors on mismatch betwen size of new and delete.");
 
   ParseFlag(str, &f->strict_memcmp, "strict_memcmp",
@@ -278,7 +278,7 @@ void InitializeFlags(Flags *f, const cha
   // https://code.google.com/p/address-sanitizer/issues/detail?id=309
   // TODO(glider,timurrrr): Fix known issues and enable this back.
   f->alloc_dealloc_mismatch = (SANITIZER_MAC == 0) && (SANITIZER_WINDOWS == 0);
-  f->new_delete_size_mismatch = true;
+  f->new_delete_type_mismatch = true;
   f->strict_memcmp = true;
   f->strict_init_order = false;
   f->start_deactivated = false;

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/sized_delete_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/sized_delete_test.cc?rev=214299&r1=214298&r2=214299&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/sized_delete_test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/sized_delete_test.cc Wed Jul 30 06:20:37 2014
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -Xclang -fsized-deallocation -O0 %s -o %t
 // RUN:                                         not %run %t 2>&1 | FileCheck %s
-// RUN: ASAN_OPTIONS=new_delete_size_mismatch=1 not %run %t 2>&1 | FileCheck %s
-// RUN: ASAN_OPTIONS=new_delete_size_mismatch=0     %run %t
+// RUN: ASAN_OPTIONS=new_delete_type_mismatch=1 not %run %t 2>&1 | FileCheck %s
+// RUN: ASAN_OPTIONS=new_delete_type_mismatch=0     %run %t
 #include <new>
 #include <stdio.h>
 
@@ -51,8 +51,10 @@ int main() {
   // Here asan should bark as we are passing a wrong type of pointer
   // to sized delete.
   Del12(reinterpret_cast<S12*>(new S20));
-  // CHECK: AddressSanitizer: new-delete-size-mismatch
-  // CHECK: sized operator delete called with size
+  // CHECK: AddressSanitizer: new-delete-type-mismatch
+  // CHECK:  object passed to delete has wrong type:
+  // CHECK:  size of the allocated type:   20 bytes;
+  // CHECK:  size of the deallocated type: 12 bytes.
   // CHECK: is located 0 bytes inside of 20-byte region
-  // CHECK: SUMMARY: AddressSanitizer: new-delete-size-mismatch
+  // CHECK: SUMMARY: AddressSanitizer: new-delete-type-mismatch
 }





More information about the llvm-commits mailing list