asan_flags.inc revision 278497
1254721Semaste//===-- asan_flags.inc ------------------------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste//
10254721Semaste// ASan runtime flags.
11254721Semaste//
12254721Semaste//===----------------------------------------------------------------------===//
13254721Semaste#ifndef ASAN_FLAG
14254721Semaste# error "Define ASAN_FLAG prior to including this file!"
15254721Semaste#endif
16254721Semaste
17254721Semaste// ASAN_FLAG(Type, Name, DefaultValue, Description)
18254721Semaste// See COMMON_FLAG in sanitizer_flags.inc for more details.
19254721Semaste
20254721SemasteASAN_FLAG(int, quarantine_size, -1,
21254721Semaste            "Deprecated, please use quarantine_size_mb.")
22254721SemasteASAN_FLAG(int, quarantine_size_mb, -1,
23254721Semaste          "Size (in Mb) of quarantine used to detect use-after-free "
24254721Semaste          "errors. Lower value may reduce memory usage but increase the "
25254721Semaste          "chance of false negatives.")
26254721SemasteASAN_FLAG(int, redzone, 16,
27254721Semaste          "Minimal size (in bytes) of redzones around heap objects. "
28254721Semaste          "Requirement: redzone >= 16, is a power of two.")
29254721SemasteASAN_FLAG(int, max_redzone, 2048,
30254721Semaste          "Maximal size (in bytes) of redzones around heap objects.")
31254721SemasteASAN_FLAG(
32254721Semaste    bool, debug, false,
33254721Semaste    "If set, prints some debugging information and does additional checks.")
34254721SemasteASAN_FLAG(
35254721Semaste    int, report_globals, 1,
36254721Semaste    "Controls the way to handle globals (0 - don't detect buffer overflow on "
37254721Semaste    "globals, 1 - detect buffer overflow, 2 - print data about registered "
38254721Semaste    "globals).")
39254721SemasteASAN_FLAG(bool, check_initialization_order, false,
40254721Semaste          "If set, attempts to catch initialization order issues.")
41254721SemasteASAN_FLAG(
42254721Semaste    bool, replace_str, true,
43254721Semaste    "If set, uses custom wrappers and replacements for libc string functions "
44254721Semaste    "to find more errors.")
45254721SemasteASAN_FLAG(bool, replace_intrin, true,
46254721Semaste          "If set, uses custom wrappers for memset/memcpy/memmove intinsics.")
47254721SemasteASAN_FLAG(bool, mac_ignore_invalid_free, false,
48254721Semaste          "Ignore invalid free() calls to work around some bugs. Used on OS X "
49254721Semaste          "only.")
50254721SemasteASAN_FLAG(bool, detect_stack_use_after_return, false,
51254721Semaste          "Enables stack-use-after-return checking at run-time.")
52254721SemasteASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
53254721Semaste          "Minimum fake stack size log.")
54254721SemasteASAN_FLAG(int, max_uar_stack_size_log,
55254721Semaste          20, // 1Mb per size class, i.e. ~11Mb per thread
56254721Semaste          "Maximum fake stack size log.")
57254721SemasteASAN_FLAG(bool, uar_noreserve, false,
58254721Semaste          "Use mmap with 'noreserve' flag to allocate fake stack.")
59254721SemasteASAN_FLAG(
60254721Semaste    int, max_malloc_fill_size, 0x1000,  // By default, fill only the first 4K.
61254721Semaste    "ASan allocator flag. max_malloc_fill_size is the maximal amount of "
62254721Semaste    "bytes that will be filled with malloc_fill_byte on malloc.")
63254721SemasteASAN_FLAG(int, malloc_fill_byte, 0xbe,
64254721Semaste          "Value used to fill the newly allocated memory.")
65254721SemasteASAN_FLAG(int, exitcode, ASAN_DEFAULT_FAILURE_EXITCODE,
66254721Semaste          "Override the program exit status if the tool found an error.")
67254721SemasteASAN_FLAG(bool, allow_user_poisoning, true,
68254721Semaste          "If set, user may manually mark memory regions as poisoned or "
69254721Semaste          "unpoisoned.")
70254721SemasteASAN_FLAG(
71254721Semaste    int, sleep_before_dying, 0,
72254721Semaste    "Number of seconds to sleep between printing an error report and "
73254721Semaste    "terminating the program. Useful for debugging purposes (e.g. when one "
74254721Semaste    "needs to attach gdb).")
75254721SemasteASAN_FLAG(bool, check_malloc_usable_size, true,
76254721Semaste          "Allows the users to work around the bug in Nvidia drivers prior to "
77254721Semaste          "295.*.")
78254721SemasteASAN_FLAG(bool, unmap_shadow_on_exit, false,
79254721Semaste          "If set, explicitly unmaps the (huge) shadow at exit.")
80254721SemasteASAN_FLAG(
81254721Semaste    bool, abort_on_error, false,
82254721Semaste    "If set, the tool calls abort() instead of _exit() after printing the "
83254721Semaste    "error report.")
84254721SemasteASAN_FLAG(bool, print_stats, false,
85254721Semaste          "Print various statistics after printing an error message or if "
86254721Semaste          "atexit=1.")
87254721SemasteASAN_FLAG(bool, print_legend, true, "Print the legend for the shadow bytes.")
88254721SemasteASAN_FLAG(bool, atexit, false,
89254721Semaste          "If set, prints ASan exit stats even after program terminates "
90254721Semaste          "successfully.")
91254721SemasteASAN_FLAG(
92254721Semaste    bool, print_full_thread_history, true,
93254721Semaste    "If set, prints thread creation stacks for the threads involved in the "
94254721Semaste    "report and their ancestors up to the main thread.")
95254721SemasteASAN_FLAG(
96254721Semaste    bool, poison_heap, true,
97254721Semaste    "Poison (or not) the heap memory on [de]allocation. Zero value is useful "
98254721Semaste    "for benchmarking the allocator or instrumentator.")
99254721SemasteASAN_FLAG(bool, poison_partial, true,
100254721Semaste          "If true, poison partially addressable 8-byte aligned words "
101254721Semaste          "(default=true). This flag affects heap and global buffers, but not "
102254721Semaste          "stack buffers.")
103254721SemasteASAN_FLAG(bool, poison_array_cookie, true,
104254721Semaste          "Poison (or not) the array cookie after operator new[].")
105254721Semaste
106254721Semaste// Turn off alloc/dealloc mismatch checker on Mac and Windows for now.
107254721Semaste// https://code.google.com/p/address-sanitizer/issues/detail?id=131
108254721Semaste// https://code.google.com/p/address-sanitizer/issues/detail?id=309
109254721Semaste// TODO(glider,timurrrr): Fix known issues and enable this back.
110254721SemasteASAN_FLAG(bool, alloc_dealloc_mismatch,
111254721Semaste          (SANITIZER_MAC == 0) && (SANITIZER_WINDOWS == 0),
112254721Semaste          "Report errors on malloc/delete, new/free, new/delete[], etc.")
113254721Semaste
114254721SemasteASAN_FLAG(bool, new_delete_type_mismatch, true,
115254721Semaste          "Report errors on mismatch betwen size of new and delete.")
116254721SemasteASAN_FLAG(bool, strict_memcmp, true,
117254721Semaste          "If true, assume that memcmp(p1, p2, n) always reads n bytes before "
118254721Semaste          "comparing p1 and p2.")
119254721SemasteASAN_FLAG(
120254721Semaste    bool, strict_init_order, false,
121254721Semaste    "If true, assume that dynamic initializers can never access globals from "
122254721Semaste    "other modules, even if the latter are already initialized.")
123254721SemasteASAN_FLAG(
124254721Semaste    bool, start_deactivated, false,
125254721Semaste    "If true, ASan tweaks a bunch of other flags (quarantine, redzone, heap "
126254721Semaste    "poisoning) to reduce memory consumption as much as possible, and "
127254721Semaste    "restores them to original values when the first instrumented module is "
128254721Semaste    "loaded into the process. This is mainly intended to be used on "
129254721Semaste    "Android. ")
130254721SemasteASAN_FLAG(
131254721Semaste    int, detect_invalid_pointer_pairs, 0,
132254721Semaste    "If non-zero, try to detect operations like <, <=, >, >= and - on "
133254721Semaste    "invalid pointer pairs (e.g. when pointers belong to different objects). "
134254721Semaste    "The bigger the value the harder we try.")
135254721SemasteASAN_FLAG(
136254721Semaste    bool, detect_container_overflow, true,
137254721Semaste    "If true, honor the container overflow  annotations. "
138254721Semaste    "See https://code.google.com/p/address-sanitizer/wiki/ContainerOverflow")
139254721SemasteASAN_FLAG(int, detect_odr_violation, 2,
140254721Semaste          "If >=2, detect violation of One-Definition-Rule (ODR); "
141254721Semaste          "If ==1, detect ODR-violation only if the two variables "
142254721Semaste          "have different sizes")
143254721SemasteASAN_FLAG(bool, dump_instruction_bytes, false,
144254721Semaste          "If true, dump 16 bytes starting at the instruction that caused SEGV")
145254721Semaste