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); 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