[PATCH] D21378: [asan] suppress new-delete-type-mismatch per ASAN_OPTIONS suppressions settings

Stephan Bergmann via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 06:40:34 PDT 2016


sberg created this revision.
sberg added a reviewer: kcc.
sberg added a subscriber: llvm-commits.
Herald added a subscriber: kubabrecka.

http://reviews.llvm.org/D21378

Files:
  lib/asan/asan_allocator.cc
  test/asan/TestCases/allocator-suppressions.cc

Index: test/asan/TestCases/allocator-suppressions.cc
===================================================================
--- /dev/null
+++ test/asan/TestCases/allocator-suppressions.cc
@@ -0,0 +1,24 @@
+// Check that without suppressions, we catch the issue.
+// RUN: %clangxx_asan -fsized-deallocation %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-FAIL %s
+// RUN: echo "interceptor_via_fun:fail_function" > %t.supp
+// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-IGNORE %s
+
+struct Base {
+  char a[10];
+};
+
+struct Derived: Base {
+  char b[10];
+};
+
+void fail_function(Base *p) {
+  delete p;
+}
+
+int main() {
+  fail_function(new Derived);
+}
+
+// CHECK-FAIL: AddressSanitizer: new-delete-type-mismatch
+// CHECK-IGNORE-NOT: AddressSanitizer: new-delete-type-mismatch
Index: lib/asan/asan_allocator.cc
===================================================================
--- lib/asan/asan_allocator.cc
+++ lib/asan/asan_allocator.cc
@@ -20,6 +20,7 @@
 #include "asan_poisoning.h"
 #include "asan_report.h"
 #include "asan_stack.h"
+#include "asan_suppressions.h"
 #include "asan_thread.h"
 #include "sanitizer_common/sanitizer_allocator_interface.h"
 #include "sanitizer_common/sanitizer_flags.h"
@@ -530,7 +531,9 @@
 
     if (delete_size && flags()->new_delete_type_mismatch &&
         delete_size != m->UsedSize()) {
-      ReportNewDeleteSizeMismatch(p, m->UsedSize(), delete_size, stack);
+      if (!IsStackTraceSuppressed(stack)) {
+        ReportNewDeleteSizeMismatch(p, m->UsedSize(), delete_size, stack);
+      }
     }
 
     QuarantineChunk(m, ptr, stack, alloc_type);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21378.60829.patch
Type: text/x-patch
Size: 1678 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160615/1580cfa9/attachment.bin>


More information about the llvm-commits mailing list