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