@@ -26,9 +26,10 @@ static const char kInterceptorName[] = "interceptor_name";
26
26
static const char kInterceptorViaFunction [] = " interceptor_via_fun" ;
27
27
static const char kInterceptorViaLibrary [] = " interceptor_via_lib" ;
28
28
static const char kODRViolation [] = " odr_violation" ;
29
+ static const char kAllocDeallocMismatch [] = " alloc_dealloc_mismatch" ;
29
30
static const char *kSuppressionTypes [] = {
30
31
kInterceptorName , kInterceptorViaFunction , kInterceptorViaLibrary ,
31
- kODRViolation };
32
+ kODRViolation , kAllocDeallocMismatch };
32
33
33
34
SANITIZER_INTERFACE_WEAK_DEF (const char *, __asan_default_suppressions, void ) {
34
35
return " " ;
@@ -62,6 +63,44 @@ bool IsODRViolationSuppressed(const char *global_var_name) {
62
63
return suppression_ctx->Match (global_var_name, kODRViolation , &s);
63
64
}
64
65
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
+
65
104
bool IsStackTraceSuppressed (const StackTrace *stack) {
66
105
if (!HaveStackTraceBasedSuppressions ())
67
106
return false ;
@@ -80,19 +119,9 @@ bool IsStackTraceSuppressed(const StackTrace *stack) {
80
119
}
81
120
82
121
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 ;
96
125
}
97
126
}
98
127
}
0 commit comments