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