@@ -26,9 +26,10 @@ static const char kInterceptorName[] = "interceptor_name";
2626static const char kInterceptorViaFunction [] = " interceptor_via_fun" ;
2727static const char kInterceptorViaLibrary [] = " interceptor_via_lib" ;
2828static const char kODRViolation [] = " odr_violation" ;
29+ static const char kAllocDeallocMismatch [] = " alloc_dealloc_mismatch" ;
2930static const char *kSuppressionTypes [] = {
3031 kInterceptorName , kInterceptorViaFunction , kInterceptorViaLibrary ,
31- kODRViolation };
32+ kODRViolation , kAllocDeallocMismatch };
3233
3334SANITIZER_INTERFACE_WEAK_DEF (const char *, __asan_default_suppressions, void ) {
3435 return " " ;
@@ -62,6 +63,44 @@ bool IsODRViolationSuppressed(const char *global_var_name) {
6263 return suppression_ctx->Match (global_var_name, kODRViolation , &s);
6364}
6465
66+ bool IsAddrSuppressed (const char *suppression, Symbolizer *symbolizer,
67+ uptr addr) {
68+ CHECK (suppression_ctx);
69+ CHECK (suppression_ctx->HasSuppressionType (suppression));
70+ CHECK (symbolizer);
71+ SymbolizedStackHolder symbolized_stack (symbolizer->SymbolizePC (addr));
72+ const SymbolizedStack *frames = symbolized_stack.get ();
73+ CHECK (frames);
74+ for (const SymbolizedStack *cur = frames; cur; cur = cur->next ) {
75+ const char *function_name = cur->info .function ;
76+ if (!function_name) {
77+ continue ;
78+ }
79+ // Match suppressions.
80+ Suppression *s;
81+ if (suppression_ctx->Match (function_name, suppression, &s)) {
82+ return true ;
83+ }
84+ }
85+ return false ;
86+ }
87+
88+ bool IsAllocDeallocMismatchSuppressed (const StackTrace *stack) {
89+ CHECK (suppression_ctx);
90+ if (!suppression_ctx->HasSuppressionType (kAllocDeallocMismatch )) {
91+ return false ;
92+ }
93+ Symbolizer *symbolizer = Symbolizer::GetOrInit ();
94+ for (uptr i = 0 ; i < stack->size && stack->trace [i]; i++) {
95+ uptr addr = stack->trace [i];
96+ // Match "alloc_dealloc_mismatch" suppressions.
97+ if (IsAddrSuppressed (kAllocDeallocMismatch , symbolizer, addr)) {
98+ return true ;
99+ }
100+ }
101+ return false ;
102+ }
103+
65104bool IsStackTraceSuppressed (const StackTrace *stack) {
66105 if (!HaveStackTraceBasedSuppressions ())
67106 return false ;
@@ -80,19 +119,9 @@ bool IsStackTraceSuppressed(const StackTrace *stack) {
80119 }
81120
82121 if (suppression_ctx->HasSuppressionType (kInterceptorViaFunction )) {
83- SymbolizedStackHolder symbolized_stack (symbolizer->SymbolizePC (addr));
84- const SymbolizedStack *frames = symbolized_stack.get ();
85- CHECK (frames);
86- for (const SymbolizedStack *cur = frames; cur; cur = cur->next ) {
87- const char *function_name = cur->info .function ;
88- if (!function_name) {
89- continue ;
90- }
91- // Match "interceptor_via_fun" suppressions.
92- if (suppression_ctx->Match (function_name, kInterceptorViaFunction ,
93- &s)) {
94- return true ;
95- }
122+ // Match "interceptor_via_func" suppressions.
123+ if (IsAddrSuppressed (kInterceptorViaFunction , symbolizer, addr)) {
124+ return true ;
96125 }
97126 }
98127 }
0 commit comments