1//===-- asan_flags.inc ------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// ASan runtime flags.
10//
11//===----------------------------------------------------------------------===//
12#ifndef ASAN_FLAG
13# error "Define ASAN_FLAG prior to including this file!"
14#endif
15
16// ASAN_FLAG(Type, Name, DefaultValue, Description)
17// See COMMON_FLAG in sanitizer_flags.inc for more details.
18
19ASAN_FLAG(int, quarantine_size, -1,
20 "Deprecated, please use quarantine_size_mb.")
21ASAN_FLAG(int, quarantine_size_mb, -1,
22 "Size (in Mb) of quarantine used to detect use-after-free "
23 "errors. Lower value may reduce memory usage but increase the "
24 "chance of false negatives.")
25ASAN_FLAG(int, thread_local_quarantine_size_kb, -1,
26 "Size (in Kb) of thread local quarantine used to detect "
27 "use-after-free errors. Lower value may reduce memory usage but "
28 "increase the chance of false negatives. It is not advised to go "
29 "lower than 64Kb, otherwise frequent transfers to global quarantine "
30 "might affect performance.")
31ASAN_FLAG(int, redzone, 16,
32 "Minimal size (in bytes) of redzones around heap objects. "
33 "Requirement: redzone >= 16, is a power of two.")
34ASAN_FLAG(int, max_redzone, 2048,
35 "Maximal size (in bytes) of redzones around heap objects.")
36ASAN_FLAG(
37 bool, debug, false,
38 "If set, prints some debugging information and does additional checks.")
39ASAN_FLAG(
40 int, report_globals, 1,
41 "Controls the way to handle globals (0 - don't detect buffer overflow on "
42 "globals, 1 - detect buffer overflow, 2 - print data about registered "
43 "globals).")
44ASAN_FLAG(bool, check_initialization_order, false,
45 "If set, attempts to catch initialization order issues.")
46ASAN_FLAG(
47 bool, replace_str, true,
48 "If set, uses custom wrappers and replacements for libc string functions "
49 "to find more errors.")
50ASAN_FLAG(bool, replace_intrin, true,
51 "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
52ASAN_FLAG(bool, detect_stack_use_after_return,
53 SANITIZER_LINUX && !SANITIZER_ANDROID,
54 "Enables stack-use-after-return checking at run-time.")
55ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
56 "Minimum fake stack size log.")
57ASAN_FLAG(int, max_uar_stack_size_log,
58 20, // 1Mb per size class, i.e. ~11Mb per thread
59 "Maximum fake stack size log.")
60ASAN_FLAG(bool, uar_noreserve, false,
61 "Use mmap with 'noreserve' flag to allocate fake stack.")
62ASAN_FLAG(
63 int, max_malloc_fill_size, 0x1000, // By default, fill only the first 4K.
64 "ASan allocator flag. max_malloc_fill_size is the maximal amount of "
65 "bytes that will be filled with malloc_fill_byte on malloc.")
66ASAN_FLAG(
67 int, max_free_fill_size, 0,
68 "ASan allocator flag. max_free_fill_size is the maximal amount of "
69 "bytes that will be filled with free_fill_byte during free.")
70ASAN_FLAG(int, malloc_fill_byte, 0xbe,
71 "Value used to fill the newly allocated memory.")
72ASAN_FLAG(int, free_fill_byte, 0x55,
73 "Value used to fill deallocated memory.")
74ASAN_FLAG(bool, allow_user_poisoning, true,
75 "If set, user may manually mark memory regions as poisoned or "
76 "unpoisoned.")
77ASAN_FLAG(
78 int, sleep_before_dying, 0,
79 "Number of seconds to sleep between printing an error report and "
80 "terminating the program. Useful for debugging purposes (e.g. when one "
81 "needs to attach gdb).")
82ASAN_FLAG(
83 int, sleep_after_init, 0,
84 "Number of seconds to sleep after AddressSanitizer is initialized. "
85 "Useful for debugging purposes (e.g. when one needs to attach gdb).")
86ASAN_FLAG(
87 int, sleep_before_init, 0,
88 "Number of seconds to sleep before AddressSanitizer starts initializing. "
89 "Useful for debugging purposes (e.g. when one needs to attach gdb).")
90ASAN_FLAG(bool, check_malloc_usable_size, true,
91 "Allows the users to work around the bug in Nvidia drivers prior to "
92 "295.*.")
93ASAN_FLAG(bool, unmap_shadow_on_exit, false,
94 "If set, explicitly unmaps the (huge) shadow at exit.")
95ASAN_FLAG(bool, protect_shadow_gap, true, "If set, mprotect the shadow gap")
96ASAN_FLAG(bool, print_stats, false,
97 "Print various statistics after printing an error message or if "
98 "atexit=1.")
99ASAN_FLAG(bool, print_legend, true, "Print the legend for the shadow bytes.")
100ASAN_FLAG(bool, print_scariness, false,
101 "Print the scariness score. Experimental.")
102ASAN_FLAG(bool, atexit, false,
103 "If set, prints ASan exit stats even after program terminates "
104 "successfully.")
105ASAN_FLAG(
106 bool, print_full_thread_history, true,
107 "If set, prints thread creation stacks for the threads involved in the "
108 "report and their ancestors up to the main thread.")
109ASAN_FLAG(
110 bool, poison_heap, true,
111 "Poison (or not) the heap memory on [de]allocation. Zero value is useful "
112 "for benchmarking the allocator or instrumentator.")
113ASAN_FLAG(bool, poison_partial, true,
114 "If true, poison partially addressable 8-byte aligned words "
115 "(default=true). This flag affects heap and global buffers, but not "
116 "stack buffers.")
117ASAN_FLAG(bool, poison_array_cookie, true,
118 "Poison (or not) the array cookie after operator new[].")
119
120// Turn off alloc/dealloc mismatch checker on Mac and Windows for now.
121// https://github.com/google/sanitizers/issues/131
122// https://github.com/google/sanitizers/issues/309
123// TODO(glider,timurrrr): Fix known issues and enable this back.
124ASAN_FLAG(bool, alloc_dealloc_mismatch,
125 !SANITIZER_APPLE && !SANITIZER_WINDOWS && !SANITIZER_ANDROID,
126 "Report errors on malloc/delete, new/free, new/delete[], etc.")
127
128ASAN_FLAG(bool, new_delete_type_mismatch, true,
129 "Report errors on mismatch between size of new and delete.")
130ASAN_FLAG(
131 bool, strict_init_order, false,
132 "If true, assume that dynamic initializers can never access globals from "
133 "other modules, even if the latter are already initialized.")
134ASAN_FLAG(
135 bool, start_deactivated, false,
136 "If true, ASan tweaks a bunch of other flags (quarantine, redzone, heap "
137 "poisoning) to reduce memory consumption as much as possible, and "
138 "restores them to original values when the first instrumented module is "
139 "loaded into the process. This is mainly intended to be used on "
140 "Android. ")
141ASAN_FLAG(
142 int, detect_invalid_pointer_pairs, 0,
143 "If >= 2, detect operations like <, <=, >, >= and - on invalid pointer "
144 "pairs (e.g. when pointers belong to different objects); "
145 "If == 1, detect invalid operations only when both pointers are non-null.")
146ASAN_FLAG(bool, detect_container_overflow, true,
147 "If true, honor the container overflow annotations. See "
148 "https://github.com/google/sanitizers/wiki/"
149 "AddressSanitizerContainerOverflow")
150ASAN_FLAG(int, detect_odr_violation, 2,
151 "If >=2, detect violation of One-Definition-Rule (ODR); "
152 "If ==1, detect ODR-violation only if the two variables "
153 "have different sizes")
154ASAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
155ASAN_FLAG(bool, halt_on_error, true,
156 "Crash the program after printing the first error report "
157 "(WARNING: USE AT YOUR OWN RISK!)")
158ASAN_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true,
159 "realloc(p, 0) is equivalent to free(p) by default (Same as the "
160 "POSIX standard). If set to false, realloc(p, 0) will return a "
161 "pointer to an allocated space which can not be used.")
162ASAN_FLAG(bool, verify_asan_link_order, true,
163 "Check position of ASan runtime in library list (needs to be disabled"
164 " when other library has to be preloaded system-wide)")
165ASAN_FLAG(
166 bool, windows_hook_rtl_allocators, false,
167 "(Windows only) enable hooking of Rtl(Allocate|Free|Size|ReAllocate)Heap.")
168

source code of compiler-rt/lib/asan/asan_flags.inc