asan_flags.inc revision 341825
1278497Sdim//===-- asan_flags.inc ------------------------------------------*- C++ -*-===//
2278497Sdim//
3278497Sdim//                     The LLVM Compiler Infrastructure
4278497Sdim//
5278497Sdim// This file is distributed under the University of Illinois Open Source
6278497Sdim// License. See LICENSE.TXT for details.
7278497Sdim//
8278497Sdim//===----------------------------------------------------------------------===//
9278497Sdim//
10278497Sdim// ASan runtime flags.
11278497Sdim//
12278497Sdim//===----------------------------------------------------------------------===//
13278497Sdim#ifndef ASAN_FLAG
14278497Sdim# error "Define ASAN_FLAG prior to including this file!"
15278497Sdim#endif
16278497Sdim
17278497Sdim// ASAN_FLAG(Type, Name, DefaultValue, Description)
18278497Sdim// See COMMON_FLAG in sanitizer_flags.inc for more details.
19278497Sdim
20278497SdimASAN_FLAG(int, quarantine_size, -1,
21278497Sdim            "Deprecated, please use quarantine_size_mb.")
22278497SdimASAN_FLAG(int, quarantine_size_mb, -1,
23278497Sdim          "Size (in Mb) of quarantine used to detect use-after-free "
24278497Sdim          "errors. Lower value may reduce memory usage but increase the "
25278497Sdim          "chance of false negatives.")
26314564SdimASAN_FLAG(int, thread_local_quarantine_size_kb, -1,
27314564Sdim          "Size (in Kb) of thread local quarantine used to detect "
28314564Sdim          "use-after-free errors. Lower value may reduce memory usage but "
29314564Sdim          "increase the chance of false negatives. It is not advised to go "
30314564Sdim          "lower than 64Kb, otherwise frequent transfers to global quarantine "
31314564Sdim          "might affect performance.")
32278497SdimASAN_FLAG(int, redzone, 16,
33278497Sdim          "Minimal size (in bytes) of redzones around heap objects. "
34278497Sdim          "Requirement: redzone >= 16, is a power of two.")
35278497SdimASAN_FLAG(int, max_redzone, 2048,
36278497Sdim          "Maximal size (in bytes) of redzones around heap objects.")
37278497SdimASAN_FLAG(
38278497Sdim    bool, debug, false,
39278497Sdim    "If set, prints some debugging information and does additional checks.")
40278497SdimASAN_FLAG(
41278497Sdim    int, report_globals, 1,
42278497Sdim    "Controls the way to handle globals (0 - don't detect buffer overflow on "
43278497Sdim    "globals, 1 - detect buffer overflow, 2 - print data about registered "
44278497Sdim    "globals).")
45278497SdimASAN_FLAG(bool, check_initialization_order, false,
46278497Sdim          "If set, attempts to catch initialization order issues.")
47278497SdimASAN_FLAG(
48278497Sdim    bool, replace_str, true,
49278497Sdim    "If set, uses custom wrappers and replacements for libc string functions "
50278497Sdim    "to find more errors.")
51278497SdimASAN_FLAG(bool, replace_intrin, true,
52309124Sdim          "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
53278497SdimASAN_FLAG(bool, detect_stack_use_after_return, false,
54278497Sdim          "Enables stack-use-after-return checking at run-time.")
55278497SdimASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
56278497Sdim          "Minimum fake stack size log.")
57278497SdimASAN_FLAG(int, max_uar_stack_size_log,
58278497Sdim          20, // 1Mb per size class, i.e. ~11Mb per thread
59278497Sdim          "Maximum fake stack size log.")
60278497SdimASAN_FLAG(bool, uar_noreserve, false,
61278497Sdim          "Use mmap with 'noreserve' flag to allocate fake stack.")
62278497SdimASAN_FLAG(
63278497Sdim    int, max_malloc_fill_size, 0x1000,  // By default, fill only the first 4K.
64278497Sdim    "ASan allocator flag. max_malloc_fill_size is the maximal amount of "
65278497Sdim    "bytes that will be filled with malloc_fill_byte on malloc.")
66321369SdimASAN_FLAG(
67321369Sdim    int, max_free_fill_size, 0,
68321369Sdim    "ASan allocator flag. max_free_fill_size is the maximal amount of "
69321369Sdim    "bytes that will be filled with free_fill_byte during free.")
70278497SdimASAN_FLAG(int, malloc_fill_byte, 0xbe,
71278497Sdim          "Value used to fill the newly allocated memory.")
72321369SdimASAN_FLAG(int, free_fill_byte, 0x55,
73321369Sdim          "Value used to fill deallocated memory.")
74278497SdimASAN_FLAG(bool, allow_user_poisoning, true,
75278497Sdim          "If set, user may manually mark memory regions as poisoned or "
76278497Sdim          "unpoisoned.")
77278497SdimASAN_FLAG(
78278497Sdim    int, sleep_before_dying, 0,
79278497Sdim    "Number of seconds to sleep between printing an error report and "
80278497Sdim    "terminating the program. Useful for debugging purposes (e.g. when one "
81278497Sdim    "needs to attach gdb).")
82327952SdimASAN_FLAG(
83327952Sdim    int, sleep_after_init, 0,
84327952Sdim    "Number of seconds to sleep after AddressSanitizer is initialized. "
85327952Sdim    "Useful for debugging purposes (e.g. when one needs to attach gdb).")
86278497SdimASAN_FLAG(bool, check_malloc_usable_size, true,
87278497Sdim          "Allows the users to work around the bug in Nvidia drivers prior to "
88278497Sdim          "295.*.")
89278497SdimASAN_FLAG(bool, unmap_shadow_on_exit, false,
90278497Sdim          "If set, explicitly unmaps the (huge) shadow at exit.")
91341825SdimASAN_FLAG(bool, protect_shadow_gap, !SANITIZER_RTEMS,
92341825Sdim          "If set, mprotect the shadow gap")
93278497SdimASAN_FLAG(bool, print_stats, false,
94278497Sdim          "Print various statistics after printing an error message or if "
95278497Sdim          "atexit=1.")
96278497SdimASAN_FLAG(bool, print_legend, true, "Print the legend for the shadow bytes.")
97309124SdimASAN_FLAG(bool, print_scariness, false,
98309124Sdim          "Print the scariness score. Experimental.")
99278497SdimASAN_FLAG(bool, atexit, false,
100278497Sdim          "If set, prints ASan exit stats even after program terminates "
101278497Sdim          "successfully.")
102278497SdimASAN_FLAG(
103278497Sdim    bool, print_full_thread_history, true,
104278497Sdim    "If set, prints thread creation stacks for the threads involved in the "
105278497Sdim    "report and their ancestors up to the main thread.")
106278497SdimASAN_FLAG(
107278497Sdim    bool, poison_heap, true,
108278497Sdim    "Poison (or not) the heap memory on [de]allocation. Zero value is useful "
109278497Sdim    "for benchmarking the allocator or instrumentator.")
110278497SdimASAN_FLAG(bool, poison_partial, true,
111278497Sdim          "If true, poison partially addressable 8-byte aligned words "
112278497Sdim          "(default=true). This flag affects heap and global buffers, but not "
113278497Sdim          "stack buffers.")
114278497SdimASAN_FLAG(bool, poison_array_cookie, true,
115278497Sdim          "Poison (or not) the array cookie after operator new[].")
116278497Sdim
117278497Sdim// Turn off alloc/dealloc mismatch checker on Mac and Windows for now.
118296417Sdim// https://github.com/google/sanitizers/issues/131
119296417Sdim// https://github.com/google/sanitizers/issues/309
120278497Sdim// TODO(glider,timurrrr): Fix known issues and enable this back.
121278497SdimASAN_FLAG(bool, alloc_dealloc_mismatch,
122314564Sdim          !SANITIZER_MAC && !SANITIZER_WINDOWS && !SANITIZER_ANDROID,
123278497Sdim          "Report errors on malloc/delete, new/free, new/delete[], etc.")
124278497Sdim
125278497SdimASAN_FLAG(bool, new_delete_type_mismatch, true,
126309124Sdim          "Report errors on mismatch between size of new and delete.")
127278497SdimASAN_FLAG(
128278497Sdim    bool, strict_init_order, false,
129278497Sdim    "If true, assume that dynamic initializers can never access globals from "
130278497Sdim    "other modules, even if the latter are already initialized.")
131278497SdimASAN_FLAG(
132278497Sdim    bool, start_deactivated, false,
133278497Sdim    "If true, ASan tweaks a bunch of other flags (quarantine, redzone, heap "
134278497Sdim    "poisoning) to reduce memory consumption as much as possible, and "
135278497Sdim    "restores them to original values when the first instrumented module is "
136278497Sdim    "loaded into the process. This is mainly intended to be used on "
137278497Sdim    "Android. ")
138278497SdimASAN_FLAG(
139278497Sdim    int, detect_invalid_pointer_pairs, 0,
140341825Sdim    "If >= 2, detect operations like <, <=, >, >= and - on invalid pointer "
141341825Sdim    "pairs (e.g. when pointers belong to different objects); "
142341825Sdim    "If == 1, detect invalid operations only when both pointers are non-null.")
143278497SdimASAN_FLAG(
144278497Sdim    bool, detect_container_overflow, true,
145296417Sdim    "If true, honor the container overflow annotations. See "
146296417Sdim    "https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow")
147278497SdimASAN_FLAG(int, detect_odr_violation, 2,
148278497Sdim          "If >=2, detect violation of One-Definition-Rule (ODR); "
149278497Sdim          "If ==1, detect ODR-violation only if the two variables "
150278497Sdim          "have different sizes")
151279194SdimASAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
152296417SdimASAN_FLAG(bool, halt_on_error, true,
153296417Sdim          "Crash the program after printing the first error report "
154296417Sdim          "(WARNING: USE AT YOUR OWN RISK!)")
155309124SdimASAN_FLAG(bool, use_odr_indicator, false,
156309124Sdim          "Use special ODR indicator symbol for ODR violation detection")
157321369SdimASAN_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true,
158321369Sdim          "realloc(p, 0) is equivalent to free(p) by default (Same as the "
159321369Sdim          "POSIX standard). If set to false, realloc(p, 0) will return a "
160321369Sdim          "pointer to an allocated space which can not be used.")
161321369SdimASAN_FLAG(bool, verify_asan_link_order, true,
162321369Sdim          "Check position of ASan runtime in library list (needs to be disabled"
163321369Sdim          " when other library has to be preloaded system-wide)")
164