@@ -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,38 @@ bool IsODRViolationSuppressed(const char *global_var_name) {
6263 return suppression_ctx->Match (global_var_name, kODRViolation , &s);
6364}
6465
66+ bool IsStackTraceSuppressedByFunction (const char *suppression,
67+ const StackTrace *stack) {
68+ CHECK (suppression_ctx);
69+ CHECK (suppression_ctx->HasSuppressionType (suppression));
70+ Symbolizer *symbolizer = Symbolizer::GetOrInit ();
71+ for (uptr i = 0 ; i < stack->size && stack->trace [i]; i++) {
72+ SymbolizedStackHolder symbolized_stack (
73+ symbolizer->SymbolizePC (stack->trace [i]));
74+ const SymbolizedStack *frames = symbolized_stack.get ();
75+ CHECK (frames);
76+ for (const SymbolizedStack *cur = frames; cur; cur = cur->next ) {
77+ const char *function_name = cur->info .function ;
78+ if (!function_name) {
79+ continue ;
80+ }
81+ // Match suppressions.
82+ Suppression *s;
83+ if (suppression_ctx->Match (function_name, suppression, &s)) {
84+ return true ;
85+ }
86+ }
87+ }
88+ return false ;
89+ }
90+
91+ bool IsAllocDeallocMismatchSuppressed (const StackTrace *stack) {
92+ CHECK (suppression_ctx);
93+ // Match "alloc_dealloc_mismatch" suppressions.
94+ return suppression_ctx->HasSuppressionType (kAllocDeallocMismatch ) &&
95+ IsStackTraceSuppressedByFunction (kAllocDeallocMismatch , stack);
96+ }
97+
6598bool IsStackTraceSuppressed (const StackTrace *stack) {
6699 if (!HaveStackTraceBasedSuppressions ())
67100 return false ;
@@ -80,19 +113,9 @@ bool IsStackTraceSuppressed(const StackTrace *stack) {
80113 }
81114
82115 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- }
116+ // Match "interceptor_via_func" suppressions.
117+ if (IsStackTraceSuppressedByFunction (kInterceptorViaFunction , stack)) {
118+ return true ;
96119 }
97120 }
98121 }
0 commit comments