OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file contains the default options for various compiler-based dynamic | 5 // This file contains the default options for various compiler-based dynamic |
6 // tools. | 6 // tools. |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX) | 10 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX) |
(...skipping 18 matching lines...) Expand all Loading... |
29 extern "C" \ | 29 extern "C" \ |
30 __attribute__((no_sanitize_address)) \ | 30 __attribute__((no_sanitize_address)) \ |
31 __attribute__((no_sanitize_memory)) \ | 31 __attribute__((no_sanitize_memory)) \ |
32 __attribute__((no_sanitize_thread)) \ | 32 __attribute__((no_sanitize_thread)) \ |
33 __attribute__((visibility("default"))) \ | 33 __attribute__((visibility("default"))) \ |
34 __attribute__((used)) | 34 __attribute__((used)) |
35 #endif | 35 #endif |
36 | 36 |
37 #if defined(ADDRESS_SANITIZER) | 37 #if defined(ADDRESS_SANITIZER) |
38 // Default options for AddressSanitizer in various configurations: | 38 // Default options for AddressSanitizer in various configurations: |
39 // strict_memcmp=1 - disable the strict memcmp() checking | |
40 // (http://crbug.com/178677 and http://crbug.com/178404). | |
41 // malloc_context_size=5 - limit the size of stack traces collected by ASan | 39 // malloc_context_size=5 - limit the size of stack traces collected by ASan |
42 // for each malloc/free by 5 frames. These stack traces tend to accumulate | 40 // for each malloc/free by 5 frames. These stack traces tend to accumulate |
43 // very fast in applications using JIT (v8 in Chrome's case), see | 41 // very fast in applications using JIT (v8 in Chrome's case), see |
44 // https://code.google.com/p/address-sanitizer/issues/detail?id=177 | 42 // https://code.google.com/p/address-sanitizer/issues/detail?id=177 |
45 // symbolize=false - disable the in-process symbolization, which isn't 100% | 43 // symbolize=false - disable the in-process symbolization, which isn't 100% |
46 // compatible with the existing sandboxes and doesn't make much sense for | 44 // compatible with the existing sandboxes and doesn't make much sense for |
47 // stripped official binaries. | 45 // stripped official binaries. |
48 // legacy_pthread_cond=1 - run in the libpthread 2.2.5 compatibility mode to | 46 // legacy_pthread_cond=1 - run in the libpthread 2.2.5 compatibility mode to |
49 // work around libGL.so using the obsolete API, see | 47 // work around libGL.so using the obsolete API, see |
50 // http://crbug.com/341805. This may break if pthread_cond_t objects are | 48 // http://crbug.com/341805. This may break if pthread_cond_t objects are |
51 // accessed by both instrumented and non-instrumented binaries (e.g. if | 49 // accessed by both instrumented and non-instrumented binaries (e.g. if |
52 // they reside in shared memory). This option is going to be deprecated in | 50 // they reside in shared memory). This option is going to be deprecated in |
53 // upstream AddressSanitizer and must not be used anywhere except the | 51 // upstream AddressSanitizer and must not be used anywhere except the |
54 // official builds. | 52 // official builds. |
55 // replace_intrin=0 - do not intercept memcpy(), memmove() and memset() to | |
56 // work around http://crbug.com/162461 (ASan report in OpenCL on Mac). | |
57 // check_printf=1 - check the memory accesses to printf (and other formatted | 53 // check_printf=1 - check the memory accesses to printf (and other formatted |
58 // output routines) arguments. | 54 // output routines) arguments. |
59 // use_sigaltstack=1 - handle signals on an alternate signal stack. Useful | 55 // use_sigaltstack=1 - handle signals on an alternate signal stack. Useful |
60 // for stack overflow detection. | 56 // for stack overflow detection. |
61 // strip_path_prefix=Release/../../ - prefixes up to and including this | 57 // strip_path_prefix=Release/../../ - prefixes up to and including this |
62 // substring will be stripped from source file paths in symbolized reports | 58 // substring will be stripped from source file paths in symbolized reports |
63 // (if symbolize=true, which is set when running with LeakSanitizer). | 59 // (if symbolize=true, which is set when running with LeakSanitizer). |
64 // fast_unwind_on_fatal=1 - use the fast (frame-pointer-based) stack unwinder | 60 // fast_unwind_on_fatal=1 - use the fast (frame-pointer-based) stack unwinder |
65 // to print error reports. V8 doesn't generate debug info for the JIT code, | 61 // to print error reports. V8 doesn't generate debug info for the JIT code, |
66 // so the slow unwinder may not work properly. | 62 // so the slow unwinder may not work properly. |
67 // detect_stack_use_after_return=1 - use fake stack to delay the reuse of | 63 // detect_stack_use_after_return=1 - use fake stack to delay the reuse of |
68 // stack allocations and detect stack-use-after-return errors. | 64 // stack allocations and detect stack-use-after-return errors. |
69 // detect_container_overflow=0 - do not detect overflows in containers | |
70 // until crbug.com/459632 is fixed. | |
71 #if defined(OS_LINUX) | 65 #if defined(OS_LINUX) |
72 #if defined(GOOGLE_CHROME_BUILD) | 66 #if defined(GOOGLE_CHROME_BUILD) |
73 // Default AddressSanitizer options for the official build. These do not affect | 67 // Default AddressSanitizer options for the official build. These do not affect |
74 // tests on buildbots (which don't set GOOGLE_CHROME_BUILD) or non-official | 68 // tests on buildbots (which don't set GOOGLE_CHROME_BUILD) or non-official |
75 // Chromium builds. | 69 // Chromium builds. |
76 const char kAsanDefaultOptions[] = | 70 const char kAsanDefaultOptions[] = |
77 "legacy_pthread_cond=1 malloc_context_size=5 strict_memcmp=0 " | 71 "legacy_pthread_cond=1 malloc_context_size=5 " |
78 "symbolize=false check_printf=1 use_sigaltstack=1 detect_leaks=0 " | 72 "symbolize=false check_printf=1 use_sigaltstack=1 detect_leaks=0 " |
79 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 " | 73 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1"; |
80 "detect_container_overflow=0 "; | |
81 #else | 74 #else |
82 // Default AddressSanitizer options for buildbots and non-official builds. | 75 // Default AddressSanitizer options for buildbots and non-official builds. |
83 const char *kAsanDefaultOptions = | 76 const char *kAsanDefaultOptions = |
84 "strict_memcmp=0 symbolize=false check_printf=1 use_sigaltstack=1 " | 77 "symbolize=false check_printf=1 use_sigaltstack=1 " |
85 "detect_leaks=0 strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 " | 78 "detect_leaks=0 strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 " |
86 "detect_stack_use_after_return=1 detect_container_overflow=0 "; | 79 "detect_stack_use_after_return=1 "; |
87 #endif // GOOGLE_CHROME_BUILD | 80 #endif // GOOGLE_CHROME_BUILD |
88 | 81 |
89 #elif defined(OS_MACOSX) | 82 #elif defined(OS_MACOSX) |
90 const char *kAsanDefaultOptions = | 83 const char *kAsanDefaultOptions = |
91 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 " | 84 "check_printf=1 use_sigaltstack=1 " |
92 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 " | 85 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 " |
93 "detect_stack_use_after_return=1 detect_odr_violation=0 " | 86 "detect_stack_use_after_return=1 detect_odr_violation=0 "; |
94 "detect_container_overflow=0 "; | |
95 static const char kNaClDefaultOptions[] = "handle_segv=0"; | 87 static const char kNaClDefaultOptions[] = "handle_segv=0"; |
96 static const char kNaClFlag[] = "--type=nacl-loader"; | 88 static const char kNaClFlag[] = "--type=nacl-loader"; |
97 #endif // OS_LINUX | 89 #endif // OS_LINUX |
98 | 90 |
99 #if defined(OS_LINUX) || defined(OS_MACOSX) | 91 #if defined(OS_LINUX) || defined(OS_MACOSX) |
100 SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_options() { | 92 SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_options() { |
101 #if defined(OS_MACOSX) | 93 #if defined(OS_MACOSX) |
102 char*** argvp = _NSGetArgv(); | 94 char*** argvp = _NSGetArgv(); |
103 int* argcp = _NSGetArgc(); | 95 int* argcp = _NSGetArgc(); |
104 if (!argvp || !argcp) return kAsanDefaultOptions; | 96 if (!argvp || !argcp) return kAsanDefaultOptions; |
105 char** argv = *argvp; | 97 char** argv = *argvp; |
106 int argc = *argcp; | 98 int argc = *argcp; |
107 for (int i = 0; i < argc; ++i) { | 99 for (int i = 0; i < argc; ++i) { |
108 if (strcmp(argv[i], kNaClFlag) == 0) { | 100 if (strcmp(argv[i], kNaClFlag) == 0) { |
109 return kNaClDefaultOptions; | 101 return kNaClDefaultOptions; |
110 } | 102 } |
111 } | 103 } |
112 #endif | 104 #endif |
113 return kAsanDefaultOptions; | 105 return kAsanDefaultOptions; |
114 } | 106 } |
| 107 |
| 108 extern "C" char kASanDefaultSuppressions[]; |
| 109 |
| 110 SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_suppressions() { |
| 111 return kASanDefaultSuppressions; |
| 112 } |
115 #endif // OS_LINUX || OS_MACOSX | 113 #endif // OS_LINUX || OS_MACOSX |
116 #endif // ADDRESS_SANITIZER | 114 #endif // ADDRESS_SANITIZER |
117 | 115 |
118 #if defined(THREAD_SANITIZER) && defined(OS_LINUX) | 116 #if defined(THREAD_SANITIZER) && defined(OS_LINUX) |
119 // Default options for ThreadSanitizer in various configurations: | 117 // Default options for ThreadSanitizer in various configurations: |
120 // detect_deadlocks=1 - enable deadlock (lock inversion) detection. | 118 // detect_deadlocks=1 - enable deadlock (lock inversion) detection. |
121 // second_deadlock_stack=1 - more verbose deadlock reports. | 119 // second_deadlock_stack=1 - more verbose deadlock reports. |
122 // report_signal_unsafe=0 - do not report async-signal-unsafe functions | 120 // report_signal_unsafe=0 - do not report async-signal-unsafe functions |
123 // called from signal handlers. | 121 // called from signal handlers. |
124 // report_thread_leaks=0 - do not report unjoined threads at the end of | 122 // report_thread_leaks=0 - do not report unjoined threads at the end of |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return kLsanDefaultOptions; | 155 return kLsanDefaultOptions; |
158 } | 156 } |
159 | 157 |
160 extern "C" char kLSanDefaultSuppressions[]; | 158 extern "C" char kLSanDefaultSuppressions[]; |
161 | 159 |
162 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() { | 160 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() { |
163 return kLSanDefaultSuppressions; | 161 return kLSanDefaultSuppressions; |
164 } | 162 } |
165 | 163 |
166 #endif // LEAK_SANITIZER | 164 #endif // LEAK_SANITIZER |
OLD | NEW |