[cfe-dev] ASan: suppress new-delete-type-mismatch via ASAN_OPTIONS suppressions?

Stephan Bergmann via cfe-dev cfe-dev at lists.llvm.org
Fri Jun 10 05:16:17 PDT 2016


I need to suppress a new-delete-type-mismatch reported in an external 
library.  ASan suggests a global 
ASAN_OPTIONS=new_delete_type_mismatch=0, but I noticed that there's an 
ASAN_OPTIONS=suppressions=... feature now, so I thought I might be able 
to make the suppression more targeted.

However, interceptor_via_fun/lib appears to only be targeting the 
various interceptors in lib/asan/asan_interceptors.cc, not 
ReportNewDeleteSizeMismatch called from lib/asan/asan_allocator.cc.  But 
a simple hack

> diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc
> index fb433bb..393f80a 100644
> --- a/lib/asan/asan_allocator.cc
> +++ b/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,6 +531,7 @@ struct Allocator {
>
>      if (delete_size && flags()->new_delete_type_mismatch &&
>          delete_size != m->UsedSize()) {
> +if (!IsStackTraceSuppressed(stack))
>        ReportNewDeleteSizeMismatch(p, m->UsedSize(), delete_size, stack);
>      }
>

showed that it would work to (mis-/re-?)use the suppression file's 
interceptor_via_fun/lib also for reports from ASan's allocation 
"interceptor".

Would that be something that is fine as-is (extending it to also cover 
other Reports from the allocator, like ReportAllocTypeMismatch called a 
few lines above in Allocator::Deallocate), or what do people think?



More information about the cfe-dev mailing list