cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / build / sanitizers / sanitizer_options.cc
blob342ab94b2cfce17cef156cb4e4d891555eeb21e9
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
3 // found in the LICENSE file.
4 //
5 // This file contains the default options for various compiler-based dynamic
6 // tools.
8 #include "build/build_config.h"
10 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX)
11 #include <crt_externs.h> // for _NSGetArgc, _NSGetArgv
12 #include <string.h>
13 #endif // ADDRESS_SANITIZER && OS_MACOSX
15 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
16 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER)
17 // Functions returning default options are declared weak in the tools' runtime
18 // libraries. To make the linker pick the strong replacements for those
19 // functions from this module, we explicitly force its inclusion by passing
20 // -Wl,-u_sanitizer_options_link_helper
21 extern "C"
22 void _sanitizer_options_link_helper() { }
24 // The callbacks we define here will be called from the sanitizer runtime, but
25 // aren't referenced from the Chrome executable. We must ensure that those
26 // callbacks are not sanitizer-instrumented, and that they aren't stripped by
27 // the linker.
28 #define SANITIZER_HOOK_ATTRIBUTE \
29 extern "C" \
30 __attribute__((no_sanitize_address)) \
31 __attribute__((no_sanitize_memory)) \
32 __attribute__((no_sanitize_thread)) \
33 __attribute__((visibility("default"))) \
34 __attribute__((used))
35 #endif
37 #if defined(ADDRESS_SANITIZER)
38 // Default options for AddressSanitizer in various configurations:
39 // malloc_context_size=5 - limit the size of stack traces collected by ASan
40 // for each malloc/free by 5 frames. These stack traces tend to accumulate
41 // very fast in applications using JIT (v8 in Chrome's case), see
42 // https://code.google.com/p/address-sanitizer/issues/detail?id=177
43 // symbolize=false - disable the in-process symbolization, which isn't 100%
44 // compatible with the existing sandboxes and doesn't make much sense for
45 // stripped official binaries.
46 // legacy_pthread_cond=1 - run in the libpthread 2.2.5 compatibility mode to
47 // work around libGL.so using the obsolete API, see
48 // http://crbug.com/341805. This may break if pthread_cond_t objects are
49 // accessed by both instrumented and non-instrumented binaries (e.g. if
50 // they reside in shared memory). This option is going to be deprecated in
51 // upstream AddressSanitizer and must not be used anywhere except the
52 // official builds.
53 // check_printf=1 - check the memory accesses to printf (and other formatted
54 // output routines) arguments.
55 // use_sigaltstack=1 - handle signals on an alternate signal stack. Useful
56 // for stack overflow detection.
57 // strip_path_prefix=Release/../../ - prefixes up to and including this
58 // substring will be stripped from source file paths in symbolized reports
59 // (if symbolize=true, which is set when running with LeakSanitizer).
60 // fast_unwind_on_fatal=1 - use the fast (frame-pointer-based) stack unwinder
61 // to print error reports. V8 doesn't generate debug info for the JIT code,
62 // so the slow unwinder may not work properly.
63 // detect_stack_use_after_return=1 - use fake stack to delay the reuse of
64 // stack allocations and detect stack-use-after-return errors.
65 #if defined(OS_LINUX)
66 #if defined(GOOGLE_CHROME_BUILD)
67 // Default AddressSanitizer options for the official build. These do not affect
68 // tests on buildbots (which don't set GOOGLE_CHROME_BUILD) or non-official
69 // Chromium builds.
70 const char kAsanDefaultOptions[] =
71 "legacy_pthread_cond=1 malloc_context_size=5 "
72 "symbolize=false check_printf=1 use_sigaltstack=1 detect_leaks=0 "
73 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1";
74 #else
75 // Default AddressSanitizer options for buildbots and non-official builds.
76 const char *kAsanDefaultOptions =
77 "symbolize=false check_printf=1 use_sigaltstack=1 "
78 "detect_leaks=0 strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 "
79 "detect_stack_use_after_return=1 ";
80 #endif // GOOGLE_CHROME_BUILD
82 #elif defined(OS_MACOSX)
83 const char *kAsanDefaultOptions =
84 "check_printf=1 use_sigaltstack=1 "
85 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 "
86 "detect_stack_use_after_return=1 detect_odr_violation=0 ";
87 static const char kNaClDefaultOptions[] = "handle_segv=0";
88 static const char kNaClFlag[] = "--type=nacl-loader";
89 #endif // OS_LINUX
91 #if defined(OS_LINUX) || defined(OS_MACOSX)
92 SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_options() {
93 #if defined(OS_MACOSX)
94 char*** argvp = _NSGetArgv();
95 int* argcp = _NSGetArgc();
96 if (!argvp || !argcp) return kAsanDefaultOptions;
97 char** argv = *argvp;
98 int argc = *argcp;
99 for (int i = 0; i < argc; ++i) {
100 if (strcmp(argv[i], kNaClFlag) == 0) {
101 return kNaClDefaultOptions;
104 #endif
105 return kAsanDefaultOptions;
108 extern "C" char kASanDefaultSuppressions[];
110 SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_suppressions() {
111 return kASanDefaultSuppressions;
113 #endif // OS_LINUX || OS_MACOSX
114 #endif // ADDRESS_SANITIZER
116 #if defined(THREAD_SANITIZER) && defined(OS_LINUX)
117 // Default options for ThreadSanitizer in various configurations:
118 // detect_deadlocks=1 - enable deadlock (lock inversion) detection.
119 // second_deadlock_stack=1 - more verbose deadlock reports.
120 // report_signal_unsafe=0 - do not report async-signal-unsafe functions
121 // called from signal handlers.
122 // report_thread_leaks=0 - do not report unjoined threads at the end of
123 // the program execution.
124 // print_suppressions=1 - print the list of matched suppressions.
125 // history_size=7 - make the history buffer proportional to 2^7 (the maximum
126 // value) to keep more stack traces.
127 // strip_path_prefix=Release/../../ - prefixes up to and including this
128 // substring will be stripped from source file paths in symbolized reports.
129 const char kTsanDefaultOptions[] =
130 "detect_deadlocks=1 second_deadlock_stack=1 report_signal_unsafe=0 "
131 "report_thread_leaks=0 print_suppressions=1 history_size=7 "
132 "strict_memcmp=0 strip_path_prefix=Release/../../ ";
134 SANITIZER_HOOK_ATTRIBUTE const char *__tsan_default_options() {
135 return kTsanDefaultOptions;
138 extern "C" char kTSanDefaultSuppressions[];
140 SANITIZER_HOOK_ATTRIBUTE const char *__tsan_default_suppressions() {
141 return kTSanDefaultSuppressions;
144 #endif // THREAD_SANITIZER && OS_LINUX
146 #if defined(MEMORY_SANITIZER)
147 // Default options for MemorySanitizer:
148 // intercept_memcmp=0 - do not detect uninitialized memory in memcmp() calls.
149 // Pending cleanup, see http://crbug.com/523428
150 // strip_path_prefix=Release/../../ - prefixes up to and including this
151 // substring will be stripped from source file paths in symbolized reports.
152 const char kMsanDefaultOptions[] =
153 "intercept_memcmp=0 strip_path_prefix=Release/../../ ";
155 SANITIZER_HOOK_ATTRIBUTE const char *__msan_default_options() {
156 return kMsanDefaultOptions;
159 #endif // MEMORY_SANITIZER
161 #if defined(LEAK_SANITIZER)
162 // Default options for LeakSanitizer:
163 // print_suppressions=1 - print the list of matched suppressions.
164 // strip_path_prefix=Release/../../ - prefixes up to and including this
165 // substring will be stripped from source file paths in symbolized reports.
166 const char kLsanDefaultOptions[] =
167 "print_suppressions=1 strip_path_prefix=Release/../../ ";
169 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_options() {
170 return kLsanDefaultOptions;
173 extern "C" char kLSanDefaultSuppressions[];
175 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() {
176 return kLSanDefaultSuppressions;
179 #endif // LEAK_SANITIZER