File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed
test/asan/TestCases/Windows Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,8 @@ void InitializeFlags() {
247
247
// See GH issue 'https://github.com/llvm/llvm-project/issues/117925' for
248
248
// details.
249
249
SetAllocatorMayReturnNull (common_flags ()->allocator_may_return_null );
250
- });
250
+ Symbolizer::UpdateSymbolizerTools ();
251
+ });
251
252
252
253
# if CAN_SANITIZE_UB
253
254
AddRegisterWeakFunctionCallback (
Original file line number Diff line number Diff line change @@ -136,6 +136,9 @@ class Symbolizer final {
136
136
// / (if it wasn't already initialized).
137
137
static Symbolizer *GetOrInit ();
138
138
static void LateInitialize ();
139
+ #if SANITIZER_WINDOWS
140
+ static void UpdateSymbolizerTools ();
141
+ #endif
139
142
// Returns a list of symbolized frames for a given address (containing
140
143
// all inlined functions, if necessary).
141
144
SymbolizedStack *SymbolizePC (uptr address);
Original file line number Diff line number Diff line change @@ -26,6 +26,19 @@ Symbolizer *Symbolizer::GetOrInit() {
26
26
return symbolizer_;
27
27
}
28
28
29
+ #if SANITIZER_WINDOWS
30
+ // If the 'symbolize' flag is set to 0, it clears the tools
31
+ // associated with the symbolizer to prevent unnecessary symbolization and
32
+ // resource usage. This is necessary because of the late binding of the
33
+ // overridden method, __asan_default_options().
34
+ void Symbolizer::UpdateSymbolizerTools () {
35
+ SpinMutexLock l (&init_mu_);
36
+ if (!common_flags ()->symbolize ) {
37
+ symbolizer_->tools_ .clear ();
38
+ }
39
+ }
40
+ #endif
41
+
29
42
// See sanitizer_symbolizer_markup.cpp.
30
43
#if !SANITIZER_SYMBOLIZER_MARKUP
31
44
Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx_asan -O0 %s -o %t
2
+ // RUN: %env_asan_opts=symbolize=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-OFF
3
+ // RUN: %env_asan_opts=symbolize=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-ON
4
+
5
+ // RUN: %clangxx_asan -O0 %s -o %t -DUSER_FUNCTION_OFF
6
+ // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-OFF
7
+ // RUN: %env_asan_opts=symbolize=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-OFF
8
+ // RUN: %env_asan_opts=symbolize=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-ON
9
+
10
+ // RUN: %clangxx_asan -O0 %s -o %t -DUSER_FUNCTION_ON
11
+ // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-ON
12
+ // RUN: %env_asan_opts=symbolize=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-OFF
13
+ // RUN: %env_asan_opts=symbolize=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SYMBOLIZE-ON
14
+ #if USER_FUNCTION_OFF
15
+
16
+ extern " C" __declspec(dllexport) extern const char *__asan_default_options () {
17
+ return " symbolize=0" ;
18
+ }
19
+
20
+ #endif
21
+
22
+ #if USER_FUNCTION_ON
23
+
24
+ extern " C" __declspec(dllexport) extern const char *__asan_default_options () {
25
+ return " symbolize=1" ;
26
+ }
27
+
28
+ #endif
29
+
30
+ #include < cstdio>
31
+ #include < cstdlib>
32
+
33
+ volatile static int heapBufferOverflowValue = 10 ;
34
+ int main () {
35
+ int *array = new int [10 ];
36
+ heapBufferOverflowValue = array[10 ]; // CHECK-SYMBOLIZE-ON: symbolize.cpp:36
37
+ return 0 ; // CHECK-SYMBOLIZE-OFF: symbolize.cpp.tmp+0x
38
+ }
You can’t perform that action at this time.
0 commit comments