1 //===-- asan_flags.h -------------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 // ASan runtime flags.
11 //===----------------------------------------------------------------------===//
16 #include "sanitizer_common/sanitizer_internal_defs.h"
18 // ASan flag values can be defined in four ways:
19 // 1) initialized with default values at startup.
20 // 2) overriden during compilation of ASan runtime by providing
21 // compile definition ASAN_DEFAULT_OPTIONS.
22 // 3) overriden from string returned by user-specified function
23 // __asan_default_options().
24 // 4) overriden from env variable ASAN_OPTIONS.
29 // Size (in bytes) of quarantine used to detect use-after-free errors.
30 // Lower value may reduce memory usage but increase the chance of
33 // Size (in bytes) of redzones around heap objects.
34 // Requirement: redzone >= 32, is a power of two.
36 // If set, prints some debugging information and does additional checks.
38 // Controls the way to handle globals (0 - don't detect buffer overflow
39 // on globals, 1 - detect buffer overflow, 2 - print data about registered
42 // If set, attempts to catch initialization order issues.
43 bool check_initialization_order
;
44 // If set, uses custom wrappers and replacements for libc string functions
45 // to find more errors.
47 // If set, uses custom wrappers for memset/memcpy/memmove intinsics.
50 bool mac_ignore_invalid_free
;
51 // Enables stack-use-after-return checking at run-time.
52 bool detect_stack_use_after_return
;
53 // The minimal fake stack size log.
54 int uar_stack_size_log
;
55 // ASan allocator flag. max_malloc_fill_size is the maximal amount of bytes
56 // that will be filled with malloc_fill_byte on malloc.
57 int max_malloc_fill_size
, malloc_fill_byte
;
58 // Override exit status if something was reported.
60 // If set, user may manually mark memory regions as poisoned or unpoisoned.
61 bool allow_user_poisoning
;
62 // Number of seconds to sleep between printing an error report and
63 // terminating application. Useful for debug purposes (when one needs
64 // to attach gdb, for example).
65 int sleep_before_dying
;
66 // If set, registers ASan custom segv handler.
68 // If set, allows user register segv handler even if ASan registers one.
69 bool allow_user_segv_handler
;
70 // If set, uses alternate stack for signal handling.
72 // Allow the users to work around the bug in Nvidia drivers prior to 295.*.
73 bool check_malloc_usable_size
;
74 // If set, explicitly unmaps (huge) shadow at exit.
75 bool unmap_shadow_on_exit
;
76 // If set, calls abort() instead of _exit() after printing an error report.
78 // Print various statistics after printing an error message or if atexit=1.
80 // Print the legend for the shadow bytes.
82 // If set, prints ASan exit stats even after program terminates successfully.
84 // If set, coverage information will be dumped at shutdown time if the
85 // appropriate instrumentation was enabled.
87 // By default, disable core dumper on 64-bit - it makes little sense
90 // Allow the tool to re-exec the program. This may interfere badly with the
93 // If set, prints not only thread creation stacks for threads in error report,
94 // but also thread creation stacks for threads that created those threads,
95 // etc. up to main thread.
96 bool print_full_thread_history
;
97 // Poison (or not) the heap memory on [de]allocation. Zero value is useful
98 // for benchmarking the allocator or instrumentator.
100 // If true, poison partially addressable 8-byte aligned words (default=true).
101 // This flag affects heap and global buffers, but not stack buffers.
103 // Report errors on malloc/delete, new/free, new/delete[], etc.
104 bool alloc_dealloc_mismatch
;
105 // If true, assume that memcmp(p1, p2, n) always reads n bytes before
106 // comparing p1 and p2.
108 // If true, assume that dynamic initializers can never access globals from
109 // other modules, even if the latter are already initialized.
110 bool strict_init_order
;
113 extern Flags asan_flags_dont_use_directly
;
114 inline Flags
*flags() {
115 return &asan_flags_dont_use_directly
;
117 void InitializeFlags(Flags
*f
, const char *env
);
119 } // namespace __asan
121 #endif // ASAN_FLAGS_H