Backed out changeset 0a133d5fd155 (bug 1864534) for causing screenshot related failur...
[gecko.git] / mozglue / build / AsanOptions.cpp
bloba96e6bd840f2bda19aa08b96194e6fe75ea91bc9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/Attributes.h"
8 #ifndef _MSC_VER // Not supported by clang-cl yet
10 // When running with AddressSanitizer, we need to explicitly set some
11 // options specific to our codebase to prevent errors during runtime.
12 // To override these, set the ASAN_OPTIONS environment variable.
14 // Currently, these are:
16 // allow_user_segv_handler=1 - Tell ASan to allow our code to use its
17 // own SIGSEGV handlers. This is required by ASM.js internally.
19 // alloc_dealloc_mismatch=0 - Disable alloc-dealloc mismatch checking
20 // in ASan. This is required because we define our own new/delete
21 // operators that are backed by malloc/free. If one of them gets inlined
22 // while the other doesn't, ASan will report false positives.
24 // detect_leaks=0 - Disable LeakSanitizer. This is required because
25 // otherwise leak checking will be enabled for various building and
26 // testing executables where we don't care much about leaks.
28 // allocator_may_return_null=1 - Tell ASan to return NULL when an allocation
29 // fails instead of aborting the program. This allows us to handle failing
30 // allocations the same way we would handle them with a regular allocator and
31 // also uncovers potential bugs that might occur in these situations.
33 // max_malloc_fill_size - Tell ASan to initialize memory to a certain value
34 // when it is allocated. This option specifies the maximum allocation size
35 // for which ASan should still initialize the memory. The value we specify
36 // here is exactly 256MiB.
38 // max_free_fill_size - Similar to max_malloc_fill_size, tell ASan to
39 // overwrite memory with a certain value when it is freed. Again, the value
40 // here specifies the maximum allocation size, larger allocations will
41 // skipped.
43 // malloc_fill_byte / free_fill_byte - These values specify the byte values
44 // used to initialize/overwrite memory in conjunction with the previous
45 // options max_malloc_fill_size and max_free_fill_size. The values used here
46 // are 0xe4 and 0xe5 to match the kAllocPoison and kAllocJunk constants used
47 // by mozjemalloc.
49 // malloc_context_size - This value specifies how many stack frames are
50 // stored for each malloc and free call. Since Firefox can have lots of deep
51 // stacks with allocations, we limit the default size here further to save
52 // some memory.
54 // fast_unwind_on_check - Use the fast (frame-pointer-based) stack unwinder
55 // for internal CHECK failures. The slow unwinder doesn't work on Android.
57 // fast_unwind_on_fatal - Use the fast (frame-pointer-based) stack unwinder
58 // to print fatal error reports. The slow unwinder doesn't work on Android.
60 // detect_stack_use_after_return=0 - Work around bug 1768099.
62 // intercept_tls_get_addr=0 - Work around
63 // https://github.com/google/sanitizers/issues/1322 (bug 1635327).
65 // !! Note: __asan_default_options is not used on Android! (bug 1576213)
66 // These should be updated in:
67 // mobile/android/geckoview/src/asan/resources/lib/*/wrap.sh
69 extern "C" MOZ_ASAN_IGNORE const char* __asan_default_options() {
70 return "allow_user_segv_handler=1:alloc_dealloc_mismatch=0:detect_leaks=0"
71 # ifdef MOZ_ASAN_REPORTER
72 ":malloc_context_size=20"
73 # endif
74 # ifdef __ANDROID__
75 ":fast_unwind_on_check=1:fast_unwind_on_fatal=1"
76 # endif
77 ":max_free_fill_size=268435456:max_malloc_fill_size=268435456"
78 ":malloc_fill_byte=228:free_fill_byte=229"
79 ":handle_sigill=1"
80 ":allocator_may_return_null=1"
81 ":detect_stack_use_after_return=0"
82 ":intercept_tls_get_addr=0";
85 // !!! Please do not add suppressions for new leaks in Gecko code, unless they
86 // are intentional !!!
87 extern "C" const char* __lsan_default_suppressions() {
88 return "# Add your suppressions below\n"
90 // LSan runs with a shallow stack depth and no debug symbols, so some
91 // small intentional leaks in system libraries show up with this. You
92 // do not want this enabled when running locally with a deep stack, as
93 // it can catch too much.
94 "leak:libc.so\n"
96 // nsComponentManagerImpl intentionally leaks factory entries, and
97 // probably some other stuff.
98 "leak:nsComponentManagerImpl\n"
100 // Bug 981220 - Pixman fails to free TLS memory.
101 "leak:pixman_implementation_lookup_composite\n"
103 // Bug 987918 - Font shutdown leaks when CLEANUP_MEMORY is not enabled.
104 "leak:libfontconfig.so\n"
105 "leak:libfreetype.so\n"
106 "leak:GI___strdup\n"
107 // The symbol is really __GI___strdup, but if you have the leading _,
108 // it doesn't suppress it.
110 // xdg_mime_init() is leaked by Gtk3 library
111 "leak:xdg_mime_init\n"
113 // Bug 1078015 - If the process terminates during a PR_Sleep, LSAN
114 // detects a leak
115 "leak:PR_Sleep\n"
117 // Bug 1363976 - Stylo holds some global data alive forever.
118 "leak:style::global_style_data\n"
119 "leak:style::sharing::SHARING_CACHE_KEY\n"
120 "leak:style::bloom::BLOOM_KEY\n"
123 // Many leaks only affect some test suites. The suite annotations are
124 // not checked.
127 // Bug 979928 - WebRTC leaks in different mochitest suites.
128 "leak:NR_reg_init\n"
129 // nr_reg_local_init should be redundant with NR_reg_init, but on
130 // Aurora we get fewer stack frames for some reason.
131 "leak:nr_reg_local_init\n"
132 "leak:r_log_register\n"
133 "leak:nr_reg_set\n"
135 // This is a one-time leak in mochitest-bc, so it is probably okay to
136 // ignore.
137 "leak:GlobalPrinters::InitializeGlobalPrinters\n"
138 "leak:nsPSPrinterList::GetPrinterList\n"
140 // Bug 1028456 - Various NSPR fd-related leaks in different mochitest
141 // suites.
142 "leak:_PR_Getfd\n"
144 // Bug 1028483 - The XML parser sometimes leaks an object. Mostly
145 // happens in toolkit/components/thumbnails.
146 "leak:processInternalEntity\n"
148 // Bug 1187421 - NSS does not always free the error stack in different
149 // mochitest suites.
150 "leak:nss_ClearErrorStack\n"
152 // Bug 1602689 - leak at mozilla::NotNull, RacyRegisteredThread,
153 // RegisteredThread::RegisteredThread, mozilla::detail::UniqueSelector
154 "leak:RegisteredThread::RegisteredThread\n"
157 // Leaks with system libraries in their stacks. These show up across a
158 // number of tests. Better symbols and disabling fast stackwalking may
159 // help diagnose these.
161 "leak:libcairo.so\n"
162 // https://github.com/OpenPrinting/cups/pull/317
163 "leak:libcups.so\n"
164 "leak:libdl.so\n"
165 "leak:libdricore.so\n"
166 "leak:libdricore9.2.1.so\n"
167 "leak:libGL.so\n"
168 "leak:libEGL_mesa.so\n"
169 "leak:libglib-2.0.so\n"
170 "leak:libglsl.so\n"
171 "leak:libp11-kit.so\n"
172 "leak:libpixman-1.so\n"
173 "leak:libpulse.so\n"
174 // lubpulsecommon 1.1 is Ubuntu 12.04
175 "leak:libpulsecommon-1.1.so\n"
176 // lubpulsecommon 1.1 is Ubuntu 16.04
177 "leak:libpulsecommon-8.0.so\n"
178 "leak:libresolv.so\n"
179 "leak:libstdc++.so\n"
180 "leak:libXrandr.so\n"
181 "leak:libX11.so\n"
182 "leak:pthread_setspecific_internal\n"
183 "leak:swrast_dri.so\n"
185 "leak:js::frontend::BytecodeEmitter:\n"
186 "leak:js::frontend::GeneralParser\n"
187 "leak:js::frontend::Parse\n"
188 "leak:xpc::CIGSHelper\n"
189 "leak:mozJSModuleLoader\n"
190 "leak:mozilla::xpcom::ConstructJSMComponent\n"
191 "leak:XPCWrappedNativeJSOps\n"
193 // End of suppressions.
194 ; // Please keep this semicolon.
197 #endif // _MSC_VER