Commit Graph

58 Commits

Author SHA1 Message Date
Alexey Samsonov 1225816a2d [Sanitizer] Change InitializeFlags() signatures. NFC.
These functions are always used to initialize singleton flags(), as
well as other global data (common_flags()).

llvm-svn: 228894
2015-02-12 00:36:42 +00:00
Evgeniy Stepanov f294d5b829 [sanitizer] Flag parser rewrite.
The new parser is a lot stricter about syntax, reports unrecognized
flags, and will make it easier to implemented some of the planned features.

llvm-svn: 226169
2015-01-15 15:13:43 +00:00
Alexey Samsonov 03499e920b [Sanitizer] Change the runtime flag representation.
This mirrors r225239 to all the rest sanitizers:
ASan, DFSan, LSan, MSan, TSan, UBSan.

Now the runtime flag type, name, default value and
description is located in the single place in the
.inc file.

llvm-svn: 225327
2015-01-07 00:38:00 +00:00
Kuba Brecka 742c471142 AddressSanitizer: Abort after failed exec() and get rid of the allow_reexec ASan flag
As mentioned in
https://code.google.com/p/address-sanitizer/issues/detail?id=365, when the
re-exec that adds the required DYLD_INSERT_LIBRARIES variable fails, ASan
currently continues to run, but things are broken (some memory can be
overwritten, interceptors don't work, ...). This patch aborts if the execv()
fails and prints an error message that DYLD_INSERT_LIBRARIES is required. It
also removes the "alllow_reexec" flag, since using it causes the same issues.

Reviewed at http://reviews.llvm.org/D6752

llvm-svn: 224712
2014-12-22 17:32:27 +00:00
Alexey Samsonov 9aca5e07ec [ASan] Move flag parsing logic to asan_flags.cc. NFC.
llvm-svn: 224450
2014-12-17 19:31:39 +00:00
Alexander Potapenko 1aba330e52 [ASan] Introduce the dump_instruction_bytes flag to print the faulting instruction upon SIGSEGV
When dump_instruction_bytes=1 and the instruction pointer doesn't point to the zero page, ASan prints 16 bytes starting at the instruction point.

llvm-svn: 218243
2014-09-22 11:58:52 +00:00
Alexey Samsonov d2d2457823 [Sanitizer] Make disable_coredump a common flag and use it in TSan
llvm-svn: 215479
2014-08-12 22:07:48 +00:00
Kostya Serebryany 522c35eb80 [asan] introduce __asan_poison_cxx_array_cookie. This is asan-rt part of PR19838 (Left OOB accesses on new[]-allocated arrays with array cookies are not detected). No tests yet. They will follow once I commit the clang part.
llvm-svn: 214711
2014-08-04 12:43:13 +00:00
Kostya Serebryany e7532e59c0 [asan] rename new-delete-size-mismatch to new-delete-type-mismatch and make the report more verbose
llvm-svn: 214299
2014-07-30 11:20:37 +00:00
Kostya Serebryany 69852a843c [asan] add a feature to detect new-delete-size-mismatch (when used with -Xclang -fsized-deallocation). Not yet on Mac. Also, remove some unused code.
llvm-svn: 214296
2014-07-30 09:48:23 +00:00
Sergey Matveev f37bd92c3a [asan] Move the "coverage" flag to common flags.
The implementation lives in sanitizer_common and will need to access that flag.

llvm-svn: 208566
2014-05-12 14:27:36 +00:00
Kostya Serebryany 4f9c31a2fa [asan] split detect_odr_violation into two: =2 detects all ODR violations, =1 detects only those where the variable sizes are different. BTW, the detector seems to be working well and finding nice bugs. Early adopters are welcome.
llvm-svn: 207415
2014-04-28 12:47:58 +00:00
Kostya Serebryany e91930a7e6 [asan] implement an experimental detector of ODR violations. Not tested yet outside of a tiny test, may need tuning.
llvm-svn: 207210
2014-04-25 08:58:28 +00:00
Kostya Serebryany 38bb53b2c5 [asan] add a run-time flag detect_container_overflow=true/false
llvm-svn: 206753
2014-04-21 14:18:45 +00:00
Alexander Potapenko c6afaace15 [ASan] Move the flag descriptions from comments to ParseFlag arguments.
llvm-svn: 204440
2014-03-21 08:37:59 +00:00
Kostya Serebryany 796f6557bf [asan] *experimental* implementation of invalid-pointer-pair detector (finds when two unrelated pointers are compared or subtracted). This implementation has both false positives and false negatives and is not tuned for performance. A bug report for a proper implementation will follow.
llvm-svn: 202389
2014-02-27 12:45:36 +00:00
Alexander Potapenko cf4bef3161 [ASan] Move the signal handling-related flags to sanitizer_common.
This change is a part of refactoring intended to have common signal handling behavior in all tools.

llvm-svn: 200295
2014-01-28 09:28:57 +00:00
Evgeniy Stepanov c61623b170 [asan] Implement delayed activation of AddressSanitizer
This change adds ASAN_OPTIONS=start_deactivated=1 flag. When present, ASan will
start in "deactivated" mode, with no heap poisoning, no quarantine, no stack
trace gathering, and minimal redzones. All this features come back when
__asan_init is called for the constructor of an instrumented library.

The primary use case for this feature is Android. Code itself is not
Android-specific, and this patch includes a Linux test for it.

llvm-svn: 199377
2014-01-16 12:31:50 +00:00
Evgeniy Stepanov 219719a2da [asan] Implement max_redzone runtime flag.
llvm-svn: 198873
2014-01-09 14:41:03 +00:00
Kostya Serebryany 1aedf6c9e6 [asan] replace the flag uar_stack_size_log with two flags min_uar_stack_size_log/max_uar_stack_size_log
llvm-svn: 197370
2013-12-16 08:42:08 +00:00
Kostya Serebryany 57bfdb080b [asan] add flag uar_noreserve to use noreserve mmap for fake stack. uar_noreserve=1 will save some memory but also negatively affect performance
llvm-svn: 197233
2013-12-13 15:03:49 +00:00
Bob Wilson a08e9ac927 Reapply asan coverage changes 194702-194704.
I still don't know what is causing our bootstrapped LTO buildbots to fail,
but llvm r194701 seems to be OK and I can't imagine that these changes could
cause the problem.

llvm-svn: 194790
2013-11-15 07:18:15 +00:00
Bob Wilson abc91eacac Speculatively revert asan coverage changes 194702-194704.
Apple's bootstrapped LTO builds have been failing, and these changes (along
with llvm 194701) are the only things on the blamelist.  I will either reapply
these changes or help debug the problem, depending on whether this fixes the
buildbots.

llvm-svn: 194779
2013-11-15 03:26:28 +00:00
Kostya Serebryany 91c52d9552 [asan] Poor man's coverage that works with ASan (compiler-rt part)
llvm-svn: 194702
2013-11-14 13:28:17 +00:00
Alexey Samsonov c5e1b16d0c [ASan] Kill use_stack_depot runtime flag and stack trace compression routines.
llvm-svn: 193868
2013-11-01 17:23:22 +00:00
Kostya Serebryany 442c4e4b1a [asan] introduce run-time flag 'poison_partial'
llvm-svn: 192793
2013-10-16 13:49:01 +00:00
Dmitry Vyukov 52ca74ec61 tsan: move verbosity flag to CommonFlags
llvm-svn: 192701
2013-10-15 13:28:51 +00:00
Kostya Serebryany 3c42ce1516 [asan] introduce run-time flag uar_stack_size_log to control the size of FakeStack; don't crash when the fake stack is exhausted, move some code to .cc file
llvm-svn: 191510
2013-09-27 11:37:23 +00:00
Kostya Serebryany c3d43ca3ec [asan] add a run-time option detect_stack_use_after_return, add verbosity output for fake stack
llvm-svn: 190932
2013-09-18 10:35:12 +00:00
Sergey Matveev 9c012165ad [lsan] Make __lsan_do_leak_check() honor the detect_leaks flag.
Also move detect_leaks to common flags.

llvm-svn: 186821
2013-07-22 12:38:17 +00:00
Evgeniy Stepanov 982d56abb8 [sanitizer] Move log_path to common flag and use it in MSan.
llvm-svn: 184836
2013-06-25 13:50:44 +00:00
Sergey Matveev 8c235f40d7 [asan] LSan hooks in asan_rtl.
llvm-svn: 182384
2013-05-21 14:15:35 +00:00
Sergey Matveev 0c8ed9ce44 [asan] Common flags in ASan.
Some flags that are common to ASan/MSan/TSan/LSan have been moved to
sanitizer_common.

llvm-svn: 181193
2013-05-06 11:27:58 +00:00
Alexey Samsonov 5c38383205 [ASan] Add allow_user_segv_handler to let users override SEGV handler installed by ASan
llvm-svn: 180255
2013-04-25 10:52:15 +00:00
Alexey Samsonov dcf0ade114 [ASan] Make init-order checker allow access to already initialized globals.
This change adds ASan runtime option "strict-init-order" (off by default)
that makes init-order checker bark if global initializer accesses any global from different
translation unit (even if the latter is already initialized). strict init-order checking
doesn't play well with, e.g. LLVM registration machineries, and causes issue 
https://code.google.com/p/address-sanitizer/issues/detail?id=178.

llvm-svn: 179843
2013-04-19 08:35:16 +00:00
Kostya Serebryany fd27b83ef2 [asan] inline flags(), up to 1% perf gain on malloc-intensive code
llvm-svn: 179307
2013-04-11 18:36:04 +00:00
Kostya Serebryany eef8bd4355 [asan] nuke the old unused allocator code
llvm-svn: 178758
2013-04-04 11:32:49 +00:00
Kostya Serebryany 13b07733b1 [asan] fill first 4K of malloc-ed memory with garbage, implement flags max_malloc_fill_size and malloc_fill_byte
llvm-svn: 178757
2013-04-04 11:17:14 +00:00
Alexander Potapenko f1c48eb509 [ASan] Add the memcmp_strict flag (1 by default) that controls the behavior of accessibility checks in memcmp.
1: memcmp(p1, p2, n) always checks n bytes
0: memcmp checks up to n bytes depending on whether the memory contents differ.

llvm-svn: 176256
2013-02-28 14:09:30 +00:00
Alexey Samsonov 0b07c63e07 [ASan] Allow ASan default runtime options be overriden at compile time by providing ASAN_DEFAULT_OPTIONS macro
llvm-svn: 175512
2013-02-19 13:14:48 +00:00
Alexander Potapenko c192af29f5 [ASan] Remove the replace_cfallocator flag, which is used no more.
See https://code.google.com/p/address-sanitizer/issues/detail?id=10 for the context.

llvm-svn: 174629
2013-02-07 15:59:37 +00:00
Evgeniy Stepanov 358698279d [sanitizer] Further split private and public sanitizer headers.
And make msan_interface.h C-compatible.

llvm-svn: 173928
2013-01-30 13:12:08 +00:00
Kostya Serebryany 6c17547ef1 [asan] two more internal flags for asan-rt: print_stats (0) and print_legend (1)
llvm-svn: 173671
2013-01-28 07:34:22 +00:00
Kostya Serebryany a11cd57a78 [asan] asan_allocator2: by default use the StackDepot to store the stack traces instead of storing them in the redzones
llvm-svn: 171099
2012-12-26 06:30:02 +00:00
Kostya Serebryany 3674c6b13b [asan] add a flag alloc_dealloc_mismatch (off by default for now) which finds malloc/delete, new/free, new/delete[], etc mismatches
llvm-svn: 170869
2012-12-21 08:53:59 +00:00
Kostya Serebryany 9da3dd0415 [asan] add a flag poison_heap to allow better allocator benchmarking, implemenet malloc_stats() on Linux
llvm-svn: 170685
2012-12-20 11:54:21 +00:00
Kostya Serebryany baf583c443 [asan] add two asan flags: fast_unwind_on_fatal and fast_unwind_on_malloc to allow using the slow CFI-based unwinder
llvm-svn: 170117
2012-12-13 09:34:23 +00:00
Kostya Serebryany 45d849c4bd [asan] add asan option log_path=PATH to let users redirect asan reports to a file PATH.PID instead of stderr
llvm-svn: 163872
2012-09-14 04:35:14 +00:00
Alexey Samsonov c402cb62fd [ASan] Add print_full_thread_history runtime option (on by default) that prints all full thread creation paths for threads involved in ASan error report
llvm-svn: 163200
2012-09-05 07:37:15 +00:00
Chandler Carruth 1aa4fef601 Relocate the external headers provided by ASan and the common sanitizer
library.

These headers are intended to be available to user code when built with
AddressSanitizer (or one of the other sanitizer's in the future) to
interface with the runtime library. As such, they form stable external
C interfaces, and the headers shouldn't be located within the
implementation.

I've pulled them out into what seem like fairly obvious locations and
names, but I'm wide open to further bikeshedding of these names and
locations.

I've updated the code and the build system to cope with the new
locations, both CMake and Makefile. Please let me know if this breaks
anyone's build.

The eventual goal is to install these headers along side the Clang
builtin headers when we build the ASan runtime and install it. My
current thinking is to locate them at:

  <prefix>/lib/clang/X.Y/include/sanitizer/common_interface_defs.h
  <prefix>/lib/clang/X.Y/include/sanitizer/asan_interface.h
  <prefix>/lib/clang/X.Y/include/sanitizer/...

But maybe others have different suggestions?

Fixing the style of the #include between these headers at least unblocks
experimentation with installing them as they now should work when
installed in these locations.

llvm-svn: 162822
2012-08-29 02:27:54 +00:00