Bug 1523562 [wpt PR 14417] - Update RTCPeerConnection-helper.js, a=testonly
[gecko.git] / mozglue / build / AsanOptions.cpp
blob04e3989bf0c152abc139de6c47093ce0904fb237
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. Enabling
27 // this will also likely require setting LSAN_OPTIONS with a suppression
28 // file, as in build/sanitizers/lsan_suppressions.txt.
30 // allocator_may_return_null=1 - Tell ASan to return NULL when an allocation
31 // fails instead of aborting the program. This allows us to handle failing
32 // allocations the same way we would handle them with a regular allocator and
33 // also uncovers potential bugs that might occur in these situations.
35 // max_malloc_fill_size - Tell ASan to initialize memory to a certain value
36 // when it is allocated. This option specifies the maximum allocation size
37 // for which ASan should still initialize the memory. The value we specify
38 // here is exactly 256MiB.
40 // max_free_fill_size - Similar to max_malloc_fill_size, tell ASan to
41 // overwrite memory with a certain value when it is freed. Again, the value
42 // here specifies the maximum allocation size, larger allocations will
43 // skipped.
45 // malloc_fill_byte / free_fill_byte - These values specify the byte values
46 // used to initialize/overwrite memory in conjunction with the previous
47 // options max_malloc_fill_size and max_free_fill_size. The values used here
48 // are 0xe4 and 0xe5 to match the kAllocPoison and kAllocJunk constants used
49 // by mozjemalloc.
51 // malloc_context_size - This value specifies how many stack frames are
52 // stored for each malloc and free call. Since Firefox can have lots of deep
53 // stacks with allocations, we limit the default size here further to save
54 // some memory.
56 extern "C" MOZ_ASAN_BLACKLIST const char* __asan_default_options() {
57 return "allow_user_segv_handler=1:alloc_dealloc_mismatch=0:detect_leaks=0"
58 # ifdef MOZ_ASAN_REPORTER
59 ":malloc_context_size=20"
60 # endif
61 ":max_free_fill_size=268435456:max_malloc_fill_size=268435456"
62 ":malloc_fill_byte=228:free_fill_byte=229"
63 ":handle_sigill=1"
64 ":allocator_may_return_null=1";
67 #endif