Dmitry Vyukov
7bd319cc08
tsan: fix flags parsing
...
- running_on_valgrind was not parsed in some contexts
- refactor code a bit
- add comprehensive tests for flags parsing
llvm-svn: 195831
2013-11-27 09:54:10 +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
6345150992
[Sanitizer] Specify a default value for each common runtime flag
...
llvm-svn: 194479
2013-11-12 13:59:08 +00:00
Alexey Samsonov
fead612a02
[ASan] Disable back init-order checker. Make strict_init_order imply check_initialization_order
...
llvm-svn: 194125
2013-11-06 04:27:09 +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
Alexey Samsonov
85cee41633
[ASan] Turn on (non-strict) initialization order checker by default for all ASan users
...
llvm-svn: 193729
2013-10-31 00:40:15 +00:00
Peter Collingbourne
791e65dcfb
Overhaul the symbolizer interface.
...
This moves away from creating the symbolizer object and initializing the
external symbolizer as separate steps. Those steps now always take place
together.
Sanitizers with a legacy requirement to specify their own symbolizer path
should use InitSymbolizer to initialize the symbolizer with the desired
path, and GetSymbolizer to access the symbolizer. Sanitizers with no
such requirement (e.g. UBSan) can use GetOrInitSymbolizer with no need for
initialization.
The symbolizer interface has been made thread-safe (as far as I can
tell) by protecting its member functions with mutexes.
Finally, the symbolizer interface no longer relies on weak externals, the
introduction of which was probably a mistake on my part.
Differential Revision: http://llvm-reviews.chandlerc.com/D1985
llvm-svn: 193448
2013-10-25 23:03:29 +00:00
Kostya Serebryany
4bf67d99f4
[asan] fix atexit stats
...
llvm-svn: 192956
2013-10-18 07:57:59 +00:00
Kostya Serebryany
8e2881d0c2
[asan] fix a failure with ASAN_OPTIONS=verbosity=1:use_sigaltstack=1
...
llvm-svn: 192892
2013-10-17 13:18:21 +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
Sergey Matveev
da9f5e7e7f
[asan] Improve thread lifetime tracking on POSIX systems.
...
Call AsanThread::Destroy() from a late-running TSD destructor.
Previously we called it before any user-registered TSD destructors, which caused
false positives in LeakSanitizer.
llvm-svn: 192585
2013-10-14 12:01:05 +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
b997c543fc
[asan] disable the detect_stack_use_after_return run-time flag by default and enable it explicitly in tests. This is done in preparation to enabling the -fsanitize=use-after-return compile-time flag by default when -fsanitize=address is present.
...
llvm-svn: 191184
2013-09-23 08:58:14 +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
Alexey Samsonov
48e256466a
[ASan] Check that getSymbolizer() is defined. Turn magic mapping constants into named variables
...
llvm-svn: 190787
2013-09-16 15:45:06 +00:00
Kostya Serebryany
627ea6391e
[asan] add a test for use-after-return and exceptions and fix it. Not 100% sure this is a complete fix, will keep looking for harder cases.
...
llvm-svn: 190603
2013-09-12 13:25:29 +00:00
Alexey Samsonov
7a36e6126b
[Sanitizer] Refactor symbolization interface: use class instead of several functions. Move some code around to get rid of extra source files
...
llvm-svn: 190410
2013-09-10 14:36:16 +00:00
Kostya Serebryany
8fc35ca008
[asan] refactor the use-after-return API so that the size class is computed at compile time instead of at run-time. compiler-rt part
...
llvm-svn: 190406
2013-09-10 13:16:26 +00:00
Alexey Samsonov
5b5c99d219
ASan, LSan, MSan: try to find llvm-symbolizer binary in PATH if it is not provided. Now we don't need to explicitly set the location of llvm-symbolizer in lit test configs.
...
llvm-svn: 189801
2013-09-03 13:22:51 +00:00
Timur Iskhodzhanov
51cda144ae
[ASan/RTL] Disable alloc_dealloc_mismatch by default on Windows
...
llvm-svn: 188541
2013-08-16 11:04:59 +00:00
Timur Iskhodzhanov
eee13914e2
Define SANITIZER_INTERFACE_ATTRIBUTE on Windows and fix all the places where SANITIZER_INTERFACE_ATTRIBUTE or SANITIZER_ATTRIBUTE_WEAK are used
...
llvm-svn: 188261
2013-08-13 11:42:45 +00:00
Sergey Matveev
6459a370a7
[lsan] Add leak_check_at_exit flag.
...
We needed a way to tell LSan to invoke leak checking only if __do_leak_check()
is called explicitly. This can now be achieved by setting
leak_check_at_exit=false.
llvm-svn: 187578
2013-08-01 14:57:07 +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
Timur Iskhodzhanov
4245f78fdd
[ASan] Use less shadow on Win 32-bit
...
llvm-svn: 186393
2013-07-16 09:47:39 +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
Alexey Samsonov
c8e7364763
[Sanitizer] support running external llvm-symbolizer on Mac
...
llvm-svn: 183730
2013-06-11 08:13:36 +00:00
Evgeniy Stepanov
0b1f41b6f4
[sanitizer] ioctl interceptor.
...
ASan: disabled by default
MSan: enabled by default
TSan: disabled
llvm-svn: 183517
2013-06-07 13:00:47 +00:00
Sergey Matveev
09886cd17a
[asan] Make ASan report the correct thread address ranges to LSan.
...
This CL enables thread support in LSan when used on top of ASan.
llvm-svn: 182854
2013-05-29 13:09:44 +00:00
Alexey Samsonov
49eb5700e2
Revert r182465 and add lsan-common library to makefile-based build
...
llvm-svn: 182470
2013-05-22 13:20:37 +00:00
Alexey Samsonov
155dd46e04
[ASan] Temporary remove leak checking from ASan, while we don't have makefile-based build for LSan
...
llvm-svn: 182465
2013-05-22 12:44:57 +00:00
Kostya Serebryany
8410a867eb
[asan] workaround for asan bug 189 (swapcontext followed by throw gets OOM kill). Also, disable swapcontext_test on non-x86. Fix lint
...
llvm-svn: 182456
2013-05-22 08:54:30 +00:00
Sergey Matveev
20ccf95f80
[lsan] Invoke leak detection with atexit().
...
Keeps it consistent between ASan and LSan.
llvm-svn: 182399
2013-05-21 17:56:45 +00:00
Sergey Matveev
17f5705d3c
[asan] Do not invoke LSan hooks unless CAN_SANITIZE_LEAKS.
...
llvm-svn: 182389
2013-05-21 15:35:34 +00:00
Sergey Matveev
8c235f40d7
[asan] LSan hooks in asan_rtl.
...
llvm-svn: 182384
2013-05-21 14:15:35 +00:00
Peter Collingbourne
ffaf2eac4d
[nolibc] Move all platforms to internal_getpid.
...
Before, we had an unused internal_getpid function for Linux, and a
platform-independent GetPid function. To make the naming conventions
consistent for syscall-like functions, the GetPid syscall wrapper
in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is
renamed to internal_getpid, bringing the Linux variant into use.
llvm-svn: 182132
2013-05-17 16:56:53 +00:00
Kostya Serebryany
aaf7275677
[asan] symbolize when possible, even if ASAN_SYMBOLIZER_PATH is not provided. On Linux this will use dl_iterate_phdr instead of /proc/self/maps, even if the symbolizer is not installed
...
llvm-svn: 182005
2013-05-16 13:04:29 +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
Sergey Matveev
0136943e03
[asan] Fix spelling in asan_rtl.cc Test commit.
...
Reviewers: kcc, glider, samsonov
Reviewed By: glider
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D676
llvm-svn: 179595
2013-04-16 14:58:45 +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
5b4267f7e7
[sanitizer] found a bug by code inspection: CHECK(a=b) instead of CHECK(a==b). Was puzzled why lint did not catch it. Turns out this check was disabled for asan source. fix all cases and enable the check
...
llvm-svn: 178872
2013-04-05 14:40:25 +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
Alexey Samsonov
a88c60b085
[ASan] Speed-up initialization-order checking: create and use fast versions of PoisonShadow functions, store copies of __asan_global descriptors in a vector instead of list of pointers. This gives 3x speedup on both benchmarks and real binaries with lots of globals.
...
llvm-svn: 178239
2013-03-28 15:42:43 +00:00
Alexey Samsonov
e586170e86
Fix unmatching ASan runtime flag for init-order checking exposed by r178158. Add a test for r178158.
...
llvm-svn: 178229
2013-03-28 09:11:20 +00:00
Alexey Samsonov
56a784d2f6
[ASan] Change the ABI of __asan_before_dynamic_init function: now it takes pointer to private string with module name. This string serves as a unique module ID in ASan runtime. compiler-rt part
...
llvm-svn: 178014
2013-03-26 13:06:12 +00:00
Alexey Samsonov
54afba8b62
[ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ASan-specific AsanThreadRegistry.
...
llvm-svn: 177634
2013-03-21 11:23:41 +00:00
Alexey Samsonov
cf025cb2e6
[ASan] Move GetCurrentThread/SetCurrentThread from AsanThreadRegistry class into plain functions: they don't actually use registry
...
llvm-svn: 177501
2013-03-20 09:23:28 +00:00
Evgeniy Stepanov
d3b56605f1
[sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.
...
llvm-svn: 177397
2013-03-19 13:54:41 +00:00
Alexey Samsonov
963be1ddd8
[ASan] turn off checking initialization order in ASan runtime by default. Instead, it should be turned on by default in the compiler
...
llvm-svn: 177058
2013-03-14 11:49:40 +00:00
Alexey Samsonov
140cd84155
[ASan] make ASan assume ASAN_OPTIONS=symbolize=1 if ASAN_EXTERNAL_SYMBOLIZER is defined
...
llvm-svn: 177036
2013-03-14 10:07:40 +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
Kostya Serebryany
abebb57272
[asan] bump kMidMemEnd to 0x4fffffffffULL since in rare cases prelink uses addresses higher than 0x3fffffffff
...
llvm-svn: 176250
2013-02-28 12:28:37 +00:00
Kostya Serebryany
1d63d13ce2
[asan] move the .preinit_array hack into a separate file (added used attribute)
...
llvm-svn: 175871
2013-02-22 07:51:26 +00:00
Alexander Potapenko
97781c4dd0
[ASan] temporarily disable alloc_dealloc_mismatch on Mac, since the previous commit caused error reports in gTest.
...
llvm-svn: 175766
2013-02-21 17:12:21 +00:00
Kostya Serebryany
d8c29210e5
[asan] on linux, run __asan_init from .preinit_array (even earlier than before)
...
llvm-svn: 175623
2013-02-20 14:28:08 +00:00
Alexey Samsonov
aadd1f2ad6
[Sanitizer] use raw syscall instead of _exit() function on Linux
...
llvm-svn: 175622
2013-02-20 13:54:32 +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
Kostya Serebryany
9f298da9bd
[asan] instrument memory accesses with unusual sizes
...
This patch makes asan instrument memory accesses with unusual sizes (e.g. 5 bytes or 10 bytes), e.g. long double or
packed structures.
Instrumentation is done with two 1-byte checks
(first and last bytes) and if the error is found
__asan_report_load_n(addr, real_size) or
__asan_report_store_n(addr, real_size)
is called.
asan-rt part
Also fix lint.
llvm-svn: 175508
2013-02-19 11:30:25 +00:00
Kostya Serebryany
fd61b6f0c8
[asan] make asan work with 7fff8000 offset and prelink
...
When prelink is installed in the system, prelink-ed
libraries map between 0x003000000000 and 0x004000000000 thus occupying the shadow Gap,
so we need so split the address space even further, like this:
|| [0x10007fff8000, 0x7fffffffffff] || HighMem ||
|| [0x02008fff7000, 0x10007fff7fff] || HighShadow ||
|| [0x004000000000, 0x02008fff6fff] || ShadowGap3 ||
|| [0x003000000000, 0x003fffffffff] || MidMem ||
|| [0x00087fff8000, 0x002fffffffff] || ShadowGap2 ||
|| [0x00067fff8000, 0x00087fff7fff] || MidShadow ||
|| [0x00008fff7000, 0x00067fff7fff] || ShadowGap ||
|| [0x00007fff8000, 0x00008fff6fff] || LowShadow ||
|| [0x000000000000, 0x00007fff7fff] || LowMem ||
Do it only if necessary.
Also added a bit of profiling code to make sure that the
mapping code is efficient.
Added a lit test to simulate prelink-ed libraries.
Unfortunately, this test does not work with binutils-gold linker.
If gold is the default linker the test silently passes.
Also replaced
__has_feature(address_sanitizer)
with
__has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
in two places.
Patch partially by Jakub Jelinek.
llvm-svn: 175263
2013-02-15 12:00:24 +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
Alexander Potapenko
dc91edad59
[ASan] Enable alloc_dealloc_mismatch by default on Darwin.
...
Enable AddressSanitizer.AllocDeallocMismatch tests.
llvm-svn: 174628
2013-02-07 15:55:21 +00:00
Kostya Serebryany
bda64b4d40
[sanitizer] make the error messages from sanitizer_common contain the actual tool name
...
llvm-svn: 174059
2013-01-31 14:11:21 +00:00
Alexey Samsonov
a0c0da8f51
[ASan] Split ASan interface header into private and public parts. Add a test that makes sure users can include interface header
...
llvm-svn: 174058
2013-01-31 13:46:14 +00:00
Kostya Serebryany
61761f182b
[asan] fix a crash in asan stats printing (initialize the allocator in __asan_init)
...
llvm-svn: 173676
2013-01-28 08:05:47 +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
8f267137c2
[asan] initialize kHighMemEnd at startup (instead of at compile time) to simplify further changes for various address space layouts. Fix asan_allocator2 for PowerPC (tested on 44-bit address space)
...
llvm-svn: 173260
2013-01-23 13:27:43 +00:00
Kostya Serebryany
84c7e47b5c
[asan] kill some dead code
...
llvm-svn: 172815
2013-01-18 13:01:44 +00:00
Kostya Serebryany
b05fc3a493
[asan] use the slow CFI-based unwinder when reporting an error. Still use the fast unwinder for malloc/free. Linux-x86-only for now.
...
llvm-svn: 172397
2013-01-14 11:01:34 +00:00
Alexey Samsonov
aaa50f06d4
ASan: Disable alloc/dealloc-mismatch checker on Mac for now (it produces weird false positives on googletest)
...
llvm-svn: 172394
2013-01-14 10:18:38 +00:00
Dmitry Vyukov
f22982bf0a
asan/tsan: move blocking mutex from asan to sanitizer_common
...
llvm-svn: 172380
2013-01-14 07:51:39 +00:00
Kostya Serebryany
b3d04ede8c
[asan] add a new interface function __asan_describe_address, useful for running asan-ified binary under a debugger (e.g. gdb)
...
llvm-svn: 171217
2012-12-29 10:18:31 +00:00
Kostya Serebryany
cb510e50e2
[asan] implement more strict checking for memset/etc parameters. Instead of checking the first and the last byte, we check the entire shadow region. This costs ~10 slowdown for the instrumented functions. Motivated by a nasty memset-buffer-overflow-by-140-bytes in chrome which was reported as a use-after-free or not at all
...
llvm-svn: 171198
2012-12-28 15:24:16 +00:00
Kostya Serebryany
1302e8d6da
[asan] enable alloc_dealloc_mismatch by default
...
llvm-svn: 171147
2012-12-27 08:08:05 +00:00
Kostya Serebryany
35cc75876a
[asan] asan_allocator2: implement adaptive redzones. Now with asan_allocator2 allocations <= 48 bytes have 16 byte redzone, allocations of 48-96 bytes -- have 32 bytes redzone, etc (max redzone is 2048). If ASAN_OPTIONS=redzone=n is set, it changes the minimal redzone size
...
llvm-svn: 171107
2012-12-26 10:41:24 +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
Alexey Samsonov
340de607a3
[ASan] don't print memory stats on CheckFailed
...
llvm-svn: 170120
2012-12-13 11:09:26 +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
Alexey Samsonov
a0e4706fe6
ASan: change the strategy we use for installing malloc/free/symbolization hooks on Linux: don't provide a default no-op implementations for hooks in runtime, and optionally call hooks if they are provided by the user. Don't force weak interface functions into runtime.
...
llvm-svn: 169641
2012-12-07 22:01:28 +00:00
Alexey Samsonov
45b6edbd1d
ASan: add new interface functions - __asan_(un)poison_stack_memory. Calls to these functions are inserted by the instrumentation pass in use-after-scope mode
...
llvm-svn: 169201
2012-12-04 01:38:15 +00:00
Kostya Serebryany
df198db1aa
[asan/tsan] get rid of kPageSize completely in favor of GetPageSizeCached(). This makes the code friendly to more platforms
...
llvm-svn: 168537
2012-11-24 05:03:11 +00:00
Kostya Serebryany
f22c697f58
[asan] get rid of some of the uses of kPageSize. The intent is to get rid of it completely to support platforms with multiple possible page sizes.
...
llvm-svn: 168517
2012-11-23 15:38:49 +00:00
Kostya Serebryany
734f1eb5f4
[asan/tsan] do not use __WORDSIZE macro, as it is glibc-private thing. Instead, define our own SANITIZER_WORDSIZE
...
llvm-svn: 168424
2012-11-21 12:38:58 +00:00
Alexey Samsonov
78c340d205
[ASan] Change __asan_set_on_error_callback to weak overridable __asan_on_error, so that ASan would call the latter even if it finds the error early (i.e. during module initialization)
...
llvm-svn: 165008
2012-10-02 14:06:39 +00:00
Alexey Samsonov
e29c6731aa
[Sanitizer/ASan] Simplify the code that prints and symbolizes stack traces. Fall back to module+offset if user-provided symbolizer failed. Use weak function __asan_symbolize instead of __asan_set_symbolize_callback in ASan interface, so that we're able to symbolize reports for errors that happen before the main() is called, for example, during module initialization.
...
llvm-svn: 165000
2012-10-02 12:11:17 +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
5c6b93bc33
[Sanitizer] Get rid of dependency between sanitizer_common and asan/tsan runtimes: implement tool-specific Die and CheckFailed functions via callbacks
...
llvm-svn: 163603
2012-09-11 09:44:48 +00:00
Alexander Potapenko
38c3f9ef2f
Remove the infinite recursion check for now, as we don't have __thread on Mac, and TSD is an overkill.
...
llvm-svn: 163393
2012-09-07 15:50:19 +00:00
Alexander Potapenko
c5adb8a700
Two minor changes:
...
-- exit from infinite recursion in CHECK()
-- print a verbose message if mapping of the shadow memory has failed.
llvm-svn: 163391
2012-09-07 15:34:40 +00:00
Evgeniy Stepanov
6e6817a823
[asan] Raise quarantine size a bit with ASAN_LOW_MEMORY.
...
Our tests expect that a 16M block will fit in the quarantine.
llvm-svn: 163384
2012-09-07 12:13:52 +00:00
Alexander Potapenko
35bc23ce58
Fix two compiler warnings: must use at least one argument for "..." in a variadic macros, signed vs. unsigned comparison.
...
llvm-svn: 163314
2012-09-06 13:31:13 +00:00
Kostya Serebryany
f9caa28ccf
[asan] increase max stack size to 256 (+test)
...
llvm-svn: 163308
2012-09-06 10:57:03 +00:00
Kostya Serebryany
ae350f66d4
[asan] increase the maximal size of malloc/free stack
...
llvm-svn: 163291
2012-09-06 04:46:47 +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
Kostya Serebryany
bb6f165952
[asan] get rid of AsanPrintf in favor of Printf from sanitizer_common
...
llvm-svn: 162746
2012-08-28 11:34:40 +00:00
Alexey Samsonov
e67a5dd8e1
[Sanitizer] Use low-level allocator in flag parsing to avoid calling malloc() before ASan/TSan initialization is done
...
llvm-svn: 162673
2012-08-27 14:04:54 +00:00
Alexey Samsonov
dc8d1f1039
[Sanitizer] move low-level (mmap-based) allocator to sanitizer_common
...
llvm-svn: 162663
2012-08-27 09:30:58 +00:00
Alexander Potapenko
00492cab3e
Revert the erroneous changes made to Makefile.old in r162547
...
Remove a spare newline from asan_rtl.cc
llvm-svn: 162548
2012-08-24 09:31:53 +00:00
Alexander Potapenko
fefc1e989c
If the program is linked to a dynamic ASan runtime which is not present in DYLD_INSERT_LIBRARIES
...
(which, in turn, is required for our interceptors to take effect), re-exec the program with
DYLD_INSERT_LIBRARIES set.
llvm-svn: 162547
2012-08-24 09:22:05 +00:00
Alexey Samsonov
419f610a74
[Sanitizer] Switch the symbolization strategy that would be used by sanitizer tools family: as compiling in-process symbolizer into runtime involves certain difficulties, we may instead launch an external symbolizer program (fork + execl) in a subprocess and communicate with it via pipe.
...
llvm-svn: 162437
2012-08-23 07:32:06 +00:00
Alexey Samsonov
a85b6b8154
[ASan] get rid of ASAN_USE_EXTERNAL_SYMBOLIZER compiler def in favor of __asan_set_symbolize_callback interface function. Now the user doesn't have to recompile ASan runtime to provide its own symbolizer
...
llvm-svn: 162358
2012-08-22 13:31:37 +00:00
Alexey Samsonov
de17f86655
[ASan] make ASan malloc/free hooks weak interface functions, overridable by user. Now the user can control malloc/free hooks without recompiling ASan runtime
...
llvm-svn: 162355
2012-08-22 10:12:47 +00:00
Kostya Serebryany
68d9c9da40
[asan] fix mac build
...
llvm-svn: 162279
2012-08-21 14:43:36 +00:00
Kostya Serebryany
676bcdb838
[asan] run-time part of the initialization order checker. Patch by Reid Watson with some bits from kcc. The sub-pass is off by default for now. On simple tests it works fine.
...
llvm-svn: 162278
2012-08-21 14:10:25 +00:00
Alexander Potapenko
9a168a7405
Use SANITIZER_INTERFACE_ATTRIBUTE instead of __attribute__((visibility("default")))
...
Export CheckFailed, asan_malloc, asan_free, asan_memalign, AsanStackTrace::CompressStack, AsanStackTrace::UncompressStack from the dynamic runtime library.
llvm-svn: 161943
2012-08-15 11:57:52 +00:00
Alexey Samsonov
517842b2fc
[ASan] make sure __asan_default_options symbol is exported
...
llvm-svn: 161873
2012-08-14 15:03:24 +00:00
Alexey Samsonov
eb39adc9fa
[ASan] make sure __asan_default_options gets default visibility, port corresponding test to lit
...
llvm-svn: 161869
2012-08-14 13:54:28 +00:00
Alexey Samsonov
b39b0fa9a0
[ASan] add __asan_set_on_error_callback into force_interface_symbols (thanks to cool test by glider@)
...
llvm-svn: 161756
2012-08-13 14:05:00 +00:00
Alexander Potapenko
8aba007fe1
Add a test checking that all the "__asan_" interface functions are present in a binary built with -dead_strip.
...
Fix force_interface_symbols() so that none of the interface symbols is stripped.
llvm-svn: 161582
2012-08-09 16:05:17 +00:00
Alexey Samsonov
f688412b8c
[ASan] Move __asan_report_error implementation to asan_report.cc
...
llvm-svn: 161574
2012-08-09 10:56:57 +00:00
Alexander Potapenko
ba6174889c
Use a switch instead of a simple condition in force_interface_symbols().
...
Otherwise Clang eliminates everything after the first interface symbol that is marked noreturn.
llvm-svn: 161573
2012-08-09 09:46:12 +00:00
Alexey Samsonov
4ce12349d6
[ASan] move some functions that describe addresses to asan_report.cc
...
llvm-svn: 161571
2012-08-09 09:06:52 +00:00
Alexey Samsonov
0295edbfd5
[ASan] add new ASan option 'strip_path_prefix' to remove useless prefices from filenames in stack traces
...
llvm-svn: 161321
2012-08-06 13:00:21 +00:00
Kostya Serebryany
bb0ade6daa
[asan] don't return from a never-return function. fix a test that had a chain of bugs instead of just one
...
llvm-svn: 160719
2012-07-25 10:56:09 +00:00
Alexey Samsonov
c145b02607
[ASan] fixup for r160712: provide a default definition for weak __asan_default_options()
...
llvm-svn: 160718
2012-07-25 10:40:57 +00:00
Alexander Potapenko
9bac1cedbc
Make __asan_default_options a weak function that returns a const char*.
...
Users may define it to override the default ASan options.
This function has to be marked with __attribute__((no_address_safety_analysis)), because it is called before ASan is fully initialized.
Add an output test checking the __asan_default_options functionality.
llvm-svn: 160712
2012-07-25 09:18:43 +00:00
Alexander Potapenko
7f3e84c9fd
For wild addresses in the shadow or shadow gap areas print an error message instead of crashing on a check.
...
Add AddressSanitizer.MemsetWildAddressTest that makes sure a proper error message is printed.
llvm-svn: 160620
2012-07-23 08:22:27 +00:00
Kostya Serebryany
78713bc574
[asan] get rid of the last operator new call in asan rtl
...
llvm-svn: 160347
2012-07-17 07:20:13 +00:00
Alexey Samsonov
2d4bd13eb6
[Sanitizer] fix CMake build
...
llvm-svn: 159988
2012-07-10 09:17:06 +00:00
Alexey Samsonov
9f666ea6ca
[ASan] move flags description to separate header, add comments about them.
...
llvm-svn: 159985
2012-07-10 07:41:27 +00:00
Alexey Samsonov
2467ca5010
[ASan] cleanup: remove dead flag
...
llvm-svn: 159934
2012-07-09 15:11:28 +00:00
Alexey Samsonov
34efb8e9b9
[ASan] Use common flags parsing machinery.
...
llvm-svn: 159933
2012-07-09 14:36:04 +00:00
Dmitry Vyukov
6fa46f7003
tsan/asan: unify atomics (move atomics from tsan to sanitizer_common)
...
llvm-svn: 159437
2012-06-29 16:58:33 +00:00
Kostya Serebryany
875f99a6bf
[asan] fix -Wsign-compare
...
llvm-svn: 159083
2012-06-23 16:30:48 +00:00
Alexey Samsonov
f8947a3360
[ASan] fix lint error
...
llvm-svn: 158905
2012-06-21 08:13:49 +00:00
Alexander Potapenko
1bde28b464
Factor the common code out of cf_free and mz_free.
...
Introduce the mac_ignore_invalid_free flag (0 by default) which makes both cf_free and mz_free ignore invalid free invocations and leak memory.
llvm-svn: 158885
2012-06-21 01:01:20 +00:00
Alexey Samsonov
156958dd0c
[Sanitizer] move all the rest re-implementations of libc functions from ASan runtime to common sanitizer runtime
...
llvm-svn: 158519
2012-06-15 13:09:52 +00:00
Alexey Samsonov
40e5128412
[Sanitizer] move ShadowRangeIsAvailable and several defines to common runtime
...
llvm-svn: 158499
2012-06-15 07:29:14 +00:00
Alexey Samsonov
ae1e171b72
[Sanitizer] move DumpProcessMap and DisableCoreDumper to common runtime
...
llvm-svn: 158490
2012-06-15 06:08:19 +00:00
Alexey Samsonov
c70d1086f6
[Sanitizer] move rest of mmap routines to common sanitizer runtime
...
llvm-svn: 158452
2012-06-14 14:42:58 +00:00
Alexey Samsonov
0c53a38abb
[Sanitizer] move portable GetEnv to common sanitizer runtime
...
llvm-svn: 158451
2012-06-14 14:07:21 +00:00
Kostya Serebryany
0b14fd855b
[asan] slow 16-byte redzones (still experimental)
...
llvm-svn: 158143
2012-06-07 09:15:48 +00:00
Alexey Samsonov
fe44fbd750
[Sanitizer] Move ReadFileToBuffer to sanitizer_common.
...
llvm-svn: 158138
2012-06-07 05:38:26 +00:00
Alexey Samsonov
40d5b772e5
[Sanitizer] Switch to common mmap/munmap routines in ASan run-time.
...
llvm-svn: 158078
2012-06-06 16:15:07 +00:00
Alexey Samsonov
e428779dbf
[Sanitizer] Use common CHECK machinery. Currently each tool has to define its own CheckFailed function.
...
llvm-svn: 158075
2012-06-06 15:22:20 +00:00
Kostya Serebryany
79437fe376
[asan] make tid u32 instead of int
...
llvm-svn: 158074
2012-06-06 15:06:58 +00:00
Alexey Samsonov
51ae983718
[Sanitizer]: Introduce a common internal printf function. For now, also use tool-specific wrappers TsanPrintf (its output is controlled by TSan flags) and AsanPrintf (which copies its results to the ASan-private buffer). Supported formats: %[z]{d,u,x}, %s, %p. Re-write all format strings in TSan according to this format (this should have no effect on 64-bit platforms).
...
llvm-svn: 158065
2012-06-06 13:11:29 +00:00
Alexey Samsonov
cd96c44dce
[ASan] more format fixes
...
llvm-svn: 158060
2012-06-06 10:54:25 +00:00
Alexey Samsonov
461820ad67
[ASan] Make printf arguments match format strings better.
...
llvm-svn: 158059
2012-06-06 10:46:00 +00:00
Alexey Samsonov
c4b201308b
[ASan] Use __sanitizer::Die() in ASan runtime.
...
llvm-svn: 158051
2012-06-06 07:02:44 +00:00
Alexey Samsonov
8602c65719
[Sanitizer] remove using namespace __sanitizer lines
...
llvm-svn: 157999
2012-06-05 14:05:09 +00:00
Alexey Samsonov
ef2e2cfd33
[Sanitizer] Use common defines for ASan and TSan runtime. Split defines between interface defines (can be visible in user code that includes interface ASan/TSan headers) and internal defines.
...
llvm-svn: 157998
2012-06-05 13:50:57 +00:00
Alexey Samsonov
1b12eda7ec
[ASan] use internal_{close,read,write} in ASan runtime.
...
llvm-svn: 157991
2012-06-05 08:48:10 +00:00
Alexey Samsonov
f5e2dc3c3d
[ASan] use internal_open from sanitizer_libc in ASan runtime
...
llvm-svn: 157986
2012-06-05 07:25:47 +00:00
Alexey Samsonov
485d3dc363
Remove file-type tags for .cc files in ASan run-time library
...
llvm-svn: 157927
2012-06-04 13:50:10 +00:00
Alexey Samsonov
4ecc8f43c7
[ASan] Use ASan option symbolize to turn on internal symbolizer (in development)
...
llvm-svn: 157924
2012-06-04 11:20:17 +00:00
Kostya Serebryany
1d35d155fd
[asan] more renaming
...
llvm-svn: 157747
2012-05-31 15:02:07 +00:00
Kostya Serebryany
8d03204204
[asan] more renaming
...
llvm-svn: 157746
2012-05-31 14:35:53 +00:00
Kostya Serebryany
1b71207f48
[asan,tsan] introduce sanitizer_common/sanitizer_defs.h and perform some renaming in asan rt. More to come.
...
llvm-svn: 157743
2012-05-31 14:11:07 +00:00
Alexander Potapenko
6e216bea86
Fix a bug in parsing boolean flags: we used to take the first char of the key=value string
...
instead of the first character of the value.
llvm-svn: 157692
2012-05-30 15:28:45 +00:00
Alexander Potapenko
93b2c7d516
Be less verbose when parsing the default options.
...
llvm-svn: 157691
2012-05-30 14:12:20 +00:00
Kostya Serebryany
458b4006b2
[asan,tsan] Add a new directory compiler-rt/lib/sanitizer_common
...
which will contain code shared between asan and tsan run-times.
Naming is hard. If you can suggest a better name for the directory -- speak up.
llvm-svn: 157611
2012-05-29 12:18:18 +00:00
Alexey Samsonov
1cbe656d66
Fixing ASan build on Win: don't use __asan_default_options
...
llvm-svn: 157608
2012-05-29 09:39:01 +00:00
Alexander Potapenko
0efd915d92
Rework the flags machinery a bit.
...
Clients may define the __asan_default_options char string containing the default options for the tool now.
llvm-svn: 157582
2012-05-28 16:21:19 +00:00
Alexander Potapenko
4e424b85e3
Typo fix.
...
llvm-svn: 157477
2012-05-25 15:56:40 +00:00
Alexander Potapenko
85e93ef612
Factor ParseAsanOptions outside __asan_init
...
llvm-svn: 157473
2012-05-25 15:37:16 +00:00
Alexander Potapenko
442002568c
Introduce the check_malloc_usable_size flag (on by default).
...
When the flag is set to zero, we do not check for errors in malloc_usable_size.
This may be useful to work around a bug in Nvidia drivers prior to 295.*
llvm-svn: 157472
2012-05-25 15:20:13 +00:00
Alexander Potapenko
a1c3c6582c
Increase error_message_buffer_size to 64K (16K is insufficient for large programs)
...
llvm-svn: 156711
2012-05-12 12:33:41 +00:00
Alexander Potapenko
66e6de10cf
Fix ReadFileToBuffer to return 0 on failure (-1 is too large if returned as size_t).
...
llvm-svn: 156538
2012-05-10 12:03:09 +00:00
Kostya Serebryany
b7f68dee45
[asan] minor change to please gcc
...
llvm-svn: 154201
2012-04-06 20:19:59 +00:00
Alexey Samsonov
6a19d5d209
[ASan] move replacements for new/delete to separate file
...
llvm-svn: 154167
2012-04-06 08:21:08 +00:00
Kostya Serebryany
1490c7996f
[asan] add flags: disable_core, abort_on_error and unmap_shadow_on_exit
...
llvm-svn: 154159
2012-04-06 01:27:11 +00:00
Alexander Potapenko
08342aa1a1
Introduce the use_sigaltstack flag (off by default), which enables using alternate
...
per-thread stacks for signal handling. This allows to print more verbose error reports
for stack overflows.
llvm-svn: 154092
2012-04-05 10:54:52 +00:00
Evgeniy Stepanov
823085a8f4
[asan] Support for %z to Printf()
...
At the moment, asan internal Printf() uses %l modifier for printing
values of size_t and related types. This works, because we control
both the implementation of Printf and all its uses, but can be a
little misleading.
This change adds support for %z to Printf(). All callers that print
sizes and pointers as integers are switched to %zu / %zx.
llvm-svn: 153177
2012-03-21 11:32:46 +00:00
Alexey Samsonov
cae79fbab9
[ASan]: re-enable noreturn attribute on posix
...
llvm-svn: 153082
2012-03-20 10:14:55 +00:00
Alexander Potapenko
fa391a7df2
[ASan] Print the parsed ASAN_OPTIONS for verbosity>0.
...
Move the flags around slightly.
llvm-svn: 152929
2012-03-16 16:38:31 +00:00
Kostya Serebryany
54a3cac5c5
[asan] fix unwinding inside libc intercepors (asan issue #46 )
...
llvm-svn: 152768
2012-03-15 01:36:00 +00:00
Kostya Serebryany
baf68ffcf8
[asan] fix -Wnull-conversion warnings
...
llvm-svn: 152747
2012-03-14 22:48:09 +00:00
Alexander Potapenko
b780ad9117
Force __asan_handle_no_return into the binary built with ASan.
...
llvm-svn: 152117
2012-03-06 11:45:59 +00:00
Alexander Potapenko
8e9d772c5a
Force __asan_set_death_callback into the resulting binary.
...
llvm-svn: 151808
2012-03-01 14:39:21 +00:00
Alexander Potapenko
7e07f56811
Introduce __asan_set_error_report_callback() to allow the client program post-process the error reports.
...
If the callback is set, Report() and Printf() print the reports into a buffer (together with stderr), which is then passed to the client.
llvm-svn: 151528
2012-02-27 14:06:48 +00:00
Evgeniy Stepanov
d84e16e6a3
Replace some #ifdef(s) with plain if(s).
...
llvm-svn: 151526
2012-02-27 13:07:29 +00:00
Alexey Samsonov
d6651509d0
AddressSanitizer: get rid of stdlib.h and add (smaller) stddef.h instead
...
llvm-svn: 151162
2012-02-22 14:07:06 +00:00
Timur Iskhodzhanov
94602b48ee
[ASan] Fix style + suppress 'long' lint warnings
...
llvm-svn: 151149
2012-02-22 09:28:14 +00:00
Alexander Potapenko
2c0ed61c7a
Move the contents of AsanProcMaps::Dump() into AsanDumpProcessMaps() for Posix systems.
...
Define AsanDumpProcessMaps as unimplemented on Windows.
This should fix the Windows build.
llvm-svn: 151147
2012-02-22 09:11:55 +00:00
Alexander Potapenko
c259ab3cac
Dump the process memory map if any of the mappings interleaves with the shadow.
...
llvm-svn: 151141
2012-02-22 08:27:32 +00:00
Timur Iskhodzhanov
a1c987ff38
[ASan] Add __asan_init to the list of C dynamic initializers to support /MD on Windows
...
llvm-svn: 151059
2012-02-21 16:24:23 +00:00
Alexey Samsonov
0d0b406aba
AddressSanitizer: use custom strtol/atoll functions
...
llvm-svn: 150812
2012-02-17 16:15:09 +00:00
Alexey Samsonov
8e7bfceb98
AddressSanitizer: fix lint
...
llvm-svn: 150802
2012-02-17 08:31:10 +00:00
Evgeniy Stepanov
5d47e9164c
[asan] Allocator tweaks for low memory systems.
...
llvm-svn: 150689
2012-02-16 13:35:11 +00:00
Kostya Serebryany
10dbd68bd2
[asan] don't do AsanDie twice
...
llvm-svn: 150641
2012-02-16 00:40:18 +00:00
Timur Iskhodzhanov
d2a9075de0
[ASan] Define an internal implementation of strchr to make stack OOB tests pass on Windows
...
llvm-svn: 150499
2012-02-14 19:33:04 +00:00
Kostya Serebryany
fcd535ba6c
[asan] implement __asan_set_death_callback
...
llvm-svn: 150414
2012-02-13 21:24:29 +00:00
Alexander Potapenko
720aaefb8d
Move the non-trivial implementation of AsanShadowRangeIsAvailable to asan_mac.cc
...
to avoid crashes on Linux and Win.
llvm-svn: 150398
2012-02-13 17:09:40 +00:00
Alexander Potapenko
ef4521e239
Check whether the shadow memory range intersects with an existing mapping.
...
This should help to detect problems with ASLR or linker tricks early.
llvm-svn: 150391
2012-02-13 15:11:23 +00:00
Evgeniy Stepanov
45fd36110b
[asan] Default visibility for __asan_handle_no_return.
...
llvm-svn: 150372
2012-02-13 11:55:24 +00:00
Timur Iskhodzhanov
7ce3e5bb8e
[asan] The first version of the RTL for Windows, reviewed at http://codereview.appspot.com/5647052
...
llvm-svn: 150185
2012-02-09 17:20:14 +00:00
Kostya Serebryany
0394da7bea
[asan] unpoison the stack before every noreturn call. Fixes asan issue 37. rt part
...
llvm-svn: 150101
2012-02-08 21:33:27 +00:00
Alexey Samsonov
e725478e2f
AddressSanitizer: replace all "real_X" calls with "REAL(X)"
...
llvm-svn: 150073
2012-02-08 13:45:31 +00:00
Alexey Samsonov
23e3b90319
AddressSanitizer: Replace __attribute__ with macro (for Win compatibility). Patch by timurrrr@google.com
...
llvm-svn: 149686
2012-02-03 08:37:19 +00:00
Kostya Serebryany
bca91defcb
[asan] new run-time flag: sleep_before_dying (asan Issue #31 )
...
llvm-svn: 149306
2012-01-31 00:52:18 +00:00
Alexander Potapenko
f519564d7c
Make compiler-rt/trunk/lib/asan compileable with Visual Studio 2008 on Windows.
...
Patch by Timur Iskhodzhanov (timurrrr@google.com )
To test:
$ cl /c *.c*
in the asan directory.
The code fails to link if you omit the "/c" part but that's one of the
next steps,
as well as a few TODO's I've put into the Windows-specific code.
llvm-svn: 149130
2012-01-27 15:15:04 +00:00
Evgeniy Stepanov
84c44a8b8b
EHABI-based stack trace on ARM.
...
The change removes the unused FLAG_fast_unwind, and forces EHABI-based unwind
on ARM, and fast (FP-based) unwind everywhere else.
llvm-svn: 148468
2012-01-19 11:34:18 +00:00