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