Commit Graph

925 Commits

Author SHA1 Message Date
Alexander Potapenko dc00c44d46 [ASan] Remove the declarations of pthread_workqueue_t and pthread_workitem_handle_t, which are used no more.
Kudos to Jeremy Huddleston Sequoia <jeremyhu@apple.com>

llvm-svn: 173143
2013-01-22 10:32:06 +00:00
Alexey Samsonov d7b901d581 ASan: use Clang -fsanitize-blacklist flag in unit tests (instead of -mllvm)
llvm-svn: 173142
2013-01-22 10:30:17 +00:00
Alexander Potapenko 0c92557fcb [ASan] Fix the path to ASan interface in interface_symbols_linux.c
llvm-svn: 173140
2013-01-22 10:13:37 +00:00
Alexander Potapenko 5ef0f677ae [ASan] Moved interface_symbols.c to lit_tests/Linux.
We already have Darwin-specific version of this test.

llvm-svn: 173136
2013-01-22 09:22:10 +00:00
Alexander Potapenko cae42d23a6 [ASan] Use dylib interposition to hook memory allocation in the dynamic runtime.
This CL drastically simplifies the way we're hooking the memory allocation routines in ASan on Mac by using dylib interposition to replace the main malloc_zone_* functions. This allows us to avoid replacing the default CFAllocator and drop the CF dependency at all.

Committing this patch will result in the static runtime being broken. A follow-up CL will switch ASan to use the dynamic runtime library.

llvm-svn: 173134
2013-01-22 09:14:54 +00:00
Alexey Samsonov a168f30073 ASan: simplify build rules for unit tests
llvm-svn: 173133
2013-01-22 07:31:28 +00:00
Alexey Samsonov 2f20275730 ASan: disable flexible mapping and offset on Android. It doesn't work for dynamic ASan runtime there
llvm-svn: 173132
2013-01-22 07:21:24 +00:00
Kostya Serebryany 56fc958506 [asan] split asan_test.cc even more
llvm-svn: 173131
2013-01-22 07:01:47 +00:00
Kostya Serebryany 81e916893d [asan] split asan_test.cc more
llvm-svn: 173130
2013-01-22 06:50:42 +00:00
Kostya Serebryany 4184b64094 [asan] split asan_test.cc to speedup parallel build (most important if building with a debug clang, which takes a couple of minutes on this large file with templates). More splits to follow
llvm-svn: 173129
2013-01-22 06:39:20 +00:00
Kostya Serebryany 031b69d8df [asan] fix linux build
llvm-svn: 173049
2013-01-21 15:04:36 +00:00
Alexander Potapenko c21aa5cb39 [ASan] Move Mac-specific tests to asan_mac_test.cc
llvm-svn: 173048
2013-01-21 14:49:55 +00:00
Alexey Samsonov b670018c9f CMake: generalize checking for target availability and add initial support for PowerPC native arch. With this patch, building LLVM on PowerPC native arch produces a working ASan runtime.
llvm-svn: 173044
2013-01-21 14:31:45 +00:00
Alexey Samsonov 362286f34c Fixup for r173021: build tests with zero-based shadow on Android only, fix condition in checking for shadow gap in asan_mapping.h
llvm-svn: 173026
2013-01-21 11:36:38 +00:00
Alexey Samsonov 6ad1d7809d ASan: build unit tests with -fsanitize-address-zero-base-shadow on Linux and Android
llvm-svn: 173021
2013-01-21 10:51:18 +00:00
Evgeniy Stepanov f940b2e381 [asan] Move *scanf declarations out of mac-only section.
llvm-svn: 173020
2013-01-21 10:33:14 +00:00
Alexey Samsonov a58bcf70a1 ASan: use dynamic lookup when building dynamic ASan runtime on Mac, because shadow mapping and offset are defined in the instrumented modules instead of runtime
llvm-svn: 173015
2013-01-21 09:07:01 +00:00
Alexey Samsonov b52d1a56f0 ASan: build runtime library with ASAN_FLEXIBLE_MAPPING_AND_OFFSET=1 as shadow mapping/offset are always emitted by the LLVM backend now
llvm-svn: 173013
2013-01-21 08:24:19 +00:00
Alexey Samsonov b399118cad CMake: add functions creating universal runtime libraries for several architectures on OS X and use them in ASan and UBSan build rules
llvm-svn: 173011
2013-01-21 08:12:20 +00:00
Alexey Samsonov 3292fde911 Temporary disable test added in r172828 as it seems to be flaky on the buildbots
llvm-svn: 172976
2013-01-20 13:41:26 +00:00
Alexey Samsonov b068483d4d CMake: Generalize build rules for different arches for sanitizer_common, asan, ubsan
llvm-svn: 172829
2013-01-18 16:51:07 +00:00
Alexander Potapenko b4ba995366 [ASan] Fix the log_path option to use different log files for parent and child processes after fork().
llvm-svn: 172828
2013-01-18 16:44:27 +00:00
Alexey Samsonov 163ab9d0a5 CMake: create AddCompilerRT module and implement convenience add_compiler_rt_object_library function
llvm-svn: 172826
2013-01-18 16:05:21 +00:00
Evgeniy Stepanov 01671c33ff [sanitizer] lint
llvm-svn: 172817
2013-01-18 13:12:56 +00:00
Kostya Serebryany 84c7e47b5c [asan] kill some dead code
llvm-svn: 172815
2013-01-18 13:01:44 +00:00
Evgeniy Stepanov a6c4a387ee [sanitizer] Rename 2 files *.h->*.inc as appropriate.
Also add a missing include.

llvm-svn: 172814
2013-01-18 13:01:18 +00:00
Alexey Samsonov 193b45f4fe CMake variables renaming: X86_64->x86_64 I386->i386
llvm-svn: 172812
2013-01-18 12:45:44 +00:00
Alexander Potapenko a6d40f638e [ASan] Fix compilation on Mac.
llvm-svn: 172810
2013-01-18 12:31:16 +00:00
Evgeniy Stepanov 91181eaa59 [sanitizer] Fix Mac build.
llvm-svn: 172809
2013-01-18 11:38:23 +00:00
Kostya Serebryany 63c36bbe5e [asan] fix two off-by-one errors that seem to affect only PowerPC because only there the stack top may be equal to the address space top. Noted by Andreas Schwab in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55975#c11 . Also make swapcontext interceptor a bit more robust
llvm-svn: 172807
2013-01-18 11:30:36 +00:00
Evgeniy Stepanov 222076e972 [sanitizer] Common *scanf interceptors.
llvm-svn: 172805
2013-01-18 11:17:23 +00:00
Alexander Potapenko 51794a390f Remove references to pthread_workqueue_additem_np(), which isn't in the official libdispatch API.
llvm-svn: 172802
2013-01-18 10:27:31 +00:00
Alexey Samsonov 9585613334 [ASan] fixes for Android build
llvm-svn: 172800
2013-01-18 09:20:06 +00:00
Kostya Serebryany 69fe0ba415 [sanitizer] reapply r172719, r172721-172723, r172725, and also fix the warning on Mac.
llvm-svn: 172791
2013-01-18 06:43:13 +00:00
Jakob Stoklund Olesen 7956e0094d Revert r172719, r172721-172723, and r172725.
The r172719 patch broke the build on Mac, the others depended on it.

compiler-rt/lib/asan/asan_interceptors.cc:78:13: error: unused function
      'SetThreadName' [-Werror,-Wunused-function]
      static void SetThreadName(const char *name) {

Orignal headlines:

  [asan] attempting to fix the Mac build
  [asan] restructure read/pread/pread64 tests
  [sanitizer] move write/pwrite/pwrite64 interceptors to common
  [msan] start using common interceptors in msan
  [tsan] move prctl interceptor from asan to common_interceptors thus enabling it for tsan too

llvm-svn: 172763
2013-01-17 22:51:56 +00:00
Alexey Samsonov 4f1885a109 [ASan] minor changes to swapcontext handling: don't clear shadow memory if context stack is too large
llvm-svn: 172727
2013-01-17 15:45:28 +00:00
Alexey Samsonov 708442294e ASan: Allow __asan_get_allocated_size(malloc(0)) to be 0 or 1
llvm-svn: 172726
2013-01-17 15:26:47 +00:00
Kostya Serebryany 87eb229241 [asan] attempting to fix the Mac build
llvm-svn: 172725
2013-01-17 15:14:20 +00:00
Kostya Serebryany 709d0dac81 [asan] restructure read/pread/pread64 tests
llvm-svn: 172723
2013-01-17 14:58:29 +00:00
Kostya Serebryany f7f5566055 [tsan] move prctl interceptor from asan to common_interceptors thus enabling it for tsan too
llvm-svn: 172719
2013-01-17 13:38:16 +00:00
Alexey Samsonov 769af07372 [ASan] fix __asan_get_ownership(p) and __asan_get_allocated_size(p) for the p = malloc(0)
llvm-svn: 172717
2013-01-17 13:25:17 +00:00
Kostya Serebryany 93ebdb5d64 [sanitizer] a bit more unification for interceptors (merge read/pread/pread64 in asan and tsan)
llvm-svn: 172713
2013-01-17 13:09:00 +00:00
Kostya Serebryany b7062cec53 [asan] asan_allocator2: fix the memalign handling (clear the first word of allocated chunk in case there is an old memalign magic)
llvm-svn: 172603
2013-01-16 09:12:14 +00:00
Kostya Serebryany d8b1f78296 [asan] enable asan_allocator2 by default on Linux. Will enable it on other platforms and remove the old one later, after additional testing. The new allocator is much faster and uses less memory
llvm-svn: 172531
2013-01-15 13:57:39 +00:00
Dmitry Vyukov 0d46b2b95e asan: fix the constant for new allocator cache
llvm-svn: 172526
2013-01-15 10:45:18 +00:00
Evgeniy Stepanov 99d91289b6 Move large part of asan_test_utils.h to sanitizer_common.
Move my_rand() to the common header.

This lets us avoid the use of rand_r in sanitizer_common tests.
There is no rand_r on Android.

llvm-svn: 172421
2013-01-14 15:12:26 +00:00
Alexey Samsonov 66b35642d4 ASan: Disable alloc/dealloc mismatch test on Android. It's not supposed to work there
llvm-svn: 172398
2013-01-14 11:07:59 +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 9de857a0be asan: enable allocator version 1 by default
llvm-svn: 172392
2013-01-14 09:03:24 +00:00
Dmitry Vyukov 38092f628b asan/tsan: fix memory allocator statistics
llvm-svn: 172390
2013-01-14 08:51:08 +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
Dmitry Vyukov a40a805f30 asan: fix FIXME on windows
llvm-svn: 172226
2013-01-11 17:57:24 +00:00
Dmitry Vyukov f5fa4c8a77 asan: weaken memory ordering, it's expensive in current implementation
llvm-svn: 172210
2013-01-11 16:02:31 +00:00
Kostya Serebryany 9a7e8ddb21 [asan] fid asan_allocator2 build
llvm-svn: 172194
2013-01-11 11:27:42 +00:00
Dmitry Vyukov 008dba6aa0 asan: always pass allocator cache to Allocate()
llvm-svn: 172193
2013-01-11 11:15:48 +00:00
Dmitry Vyukov b1c0dbe2c6 asan: faster quarantine
llvm-svn: 172192
2013-01-11 11:03:35 +00:00
Dmitry Vyukov 0b7bce5ecf asan: set ASAN_ALLOCATOR_VERSION=1 back
llvm-svn: 172184
2013-01-11 08:08:31 +00:00
Dmitry Vyukov db0cf871d4 asan: Refactor asan memory quarantine.
llvm-svn: 172183
2013-01-11 08:07:43 +00:00
Kostya Serebryany e54a9e6fbf [asan] don't fail the test if prctl(PR_SET_NAME) is not supported
llvm-svn: 172059
2013-01-10 11:55:43 +00:00
Kostya Serebryany 8cc7b627b4 [asan] asan_allocator2: do less work under the quarantine lock; make the strcasecmp test more resistant to the contents of unaddressable memory
llvm-svn: 172048
2013-01-10 09:25:16 +00:00
Kostya Serebryany 4dd086841f [asan] better protect the tests from memset/memcpy inlining, explicitly include unistd.h
llvm-svn: 172045
2013-01-10 06:38:43 +00:00
Kostya Serebryany 9756e2e0b3 [asan] make LargeOOBInMemset test resistant to clever compiler optimizations
llvm-svn: 171223
2012-12-29 14:42:48 +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 9479a85963 [asan] fix a build warning
llvm-svn: 171200
2012-12-28 15:55:43 +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
Alexey Samsonov 1aa47efd2c [ASan] use macro instead of raw __attribute__
llvm-svn: 171188
2012-12-28 11:22:23 +00:00
Alexey Samsonov f96bfd8849 Make ASan and TSan tests a bit less brittle with @LINE FileCheck macro
llvm-svn: 171181
2012-12-28 08:38:09 +00:00
Kostya Serebryany 4a42cf69a6 [sanitizer] add statistics to the allocator; fix lint
llvm-svn: 171161
2012-12-27 14:09:19 +00:00
Alexey Samsonov c20f5d2246 Define COMPILER_RT_CAN_EXECUTE_TESTS variable on platforms where we can produce working binaries and use it in build rules for sanitizers tests
llvm-svn: 171160
2012-12-27 13:19:23 +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 4a0d946a43 [asan] relax asan/lit_tests/malloc_delete_mismatch.cc to make it pass on Mac 10.7 (where extra frames creep in between malloc and main)
llvm-svn: 171145
2012-12-27 07:40:24 +00:00
Kostya Serebryany 6f604b5007 [asan/tsan] when unmapping a chunk of user memory, apply madvise(MADV_DONTNEED) to the corresponding chunk of shadow memory. Also update sanitizer_allocator64_testlib.cc
llvm-svn: 171144
2012-12-27 07:37:24 +00:00
Alexey Samsonov d66b12b701 [ASan] Teach ASan to print demangled function name when describing stack frame
llvm-svn: 171112
2012-12-26 14:44:46 +00:00
Kostya Serebryany 390cf94f88 [asan] asan_allocator2: do not align the requested size to the redzone size (saves a bit more memory)
llvm-svn: 171111
2012-12-26 12:20:35 +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 27ad15e165 [asan] asan_allocator2: store the user requested size in just 32 bits (larger sizes use metadata). This allows to put one more 32-bit field into the chunk header
llvm-svn: 171089
2012-12-26 04:52:07 +00:00
Kostya Serebryany eff9b4b9b1 [asan] add a test for right OOB with special large sizes. Fix this test in asan_allocator2. More test tweaking for allocator2
llvm-svn: 171058
2012-12-25 09:40:20 +00:00
Kostya Serebryany 181f504d82 [asan] properly define ASAN_LOW_MEMORY. Due to a mistake it has been always true causing redzone and quarantine sizes to be smaller than it was some time before (and out of sync with the documentation). Also make one test less greedy
llvm-svn: 171052
2012-12-25 07:17:17 +00:00
Kostya Serebryany db3250b8b3 [sanitizer] fix gcc warnings, enable one tests under asan_allocator2
llvm-svn: 171036
2012-12-24 14:53:13 +00:00
Kostya Serebryany fe80f080ee [asan] asan_allocator2 fix two asserts that happen on full chrome: a) memalign called with 0 size and large alignment and b) malloc called after TSD has been destructed
llvm-svn: 170900
2012-12-21 14:54:46 +00:00
Alexey Samsonov e30a84f08f [Sanitizer] CMake build rules for unittests: depend on headers when compiling a file with custom clang.
llvm-svn: 170897
2012-12-21 14:04:52 +00:00
Kostya Serebryany 3cc719fdf9 [asan] asan_allocator2: better memory stats
llvm-svn: 170888
2012-12-21 12:26:31 +00:00
Alexander Potapenko 47a03a2ebe [ASan] Fix another FileCheck pattern to be c++filt-proof.
llvm-svn: 170878
2012-12-21 10:48:30 +00:00
Alexey Samsonov 53a965e125 [Sanitizer] Don't implicitly add object files to the list of dependencies when building compiler_rt unittests. Fix sanitizer_common and asan build rules accordingly. This also fixes check-sanitizer command on Ninja.
llvm-svn: 170870
2012-12-21 08:56:14 +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
Richard Relph 27cfe1c1b5 Clean up some warnings that become errors. Seen in Xcode.
llvm-svn: 170843
2012-12-21 05:17:13 +00:00
Alexey Samsonov 19e8b7ecba [ASan] remove duplicate entry in shadow byte legend
llvm-svn: 170701
2012-12-20 15:19:10 +00:00
Kostya Serebryany c0d8ca5537 [asan] asan_allocator2: implement memalign
llvm-svn: 170697
2012-12-20 14:35:06 +00:00
Alexander Potapenko 5e9e51874e [ASan] Make the FileCheck pattern more c++filt-resistant.
This test didn't pass for me locally because of "T0's stack" being converted to "T0'short stack" by c++filt.
Strange enough this doesn't show up on our bots.

llvm-svn: 170690
2012-12-20 13:17:49 +00:00
Kostya Serebryany 8627af3779 [asan] add memalign tests
llvm-svn: 170687
2012-12-20 12:11:52 +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 ab8d33184d [asan] asan_allocator2: make all remaining tests pass.
llvm-svn: 170680
2012-12-20 08:53:41 +00:00
Kostya Serebryany f855bbc2f3 [asan] add ASAN_PCRE_DOTALL to two new multi-line regexps
llvm-svn: 170677
2012-12-20 07:26:33 +00:00
Alexey Samsonov 74cbc4ccd7 [ASan] don't use -fsanitize=address linker flag for unit tests on Android
llvm-svn: 170670
2012-12-20 06:16:50 +00:00
Alexey Samsonov 826b324cb0 [ASan] explicitly link with dynamic ASan runtime when building unittests on Android
llvm-svn: 170552
2012-12-19 15:52:30 +00:00
Alexey Samsonov 85bd73d259 [ASan] Support building both 32- and 64-bit unit tests if we can target both architectures
llvm-svn: 170549
2012-12-19 15:17:23 +00:00
Kostya Serebryany dcdeecb257 [asan] asan_allocator2: add mmap/munmap stats
llvm-svn: 170548
2012-12-19 14:56:38 +00:00
Alexey Samsonov b29d37bea5 [ASan] make sure Android unittests depend on ASan runtime
llvm-svn: 170543
2012-12-19 13:46:58 +00:00
Alexey Samsonov ca7fcf2354 Significantly change the way we build ASan unittests in CMake
build tree. Now just-built Clang is used to:
  1) compile instrumented sources (as before);
  2) compile non-instrumented sources;
  3) compile our own instrumented version of googletest;
  4) link it all together using -fsanitize=address flag
     (instead of trying to copy linker behavior in
      CMake build rules).

This makes ASan unittests pretty much self-consistent
and independent of other LLVM libraries.

llvm-svn: 170541
2012-12-19 12:33:39 +00:00
Alexander Potapenko 7e1fcb8136 [ASan] Change the boilerplate check in the libdispatch tests to fix them.
llvm-svn: 170531
2012-12-19 11:26:41 +00:00
Kostya Serebryany d5c46cb2f7 [asan] print the shadow bytes in different colors and also output the shadow byte legend
llvm-svn: 170520
2012-12-19 09:53:32 +00:00
Kostya Serebryany 479f05b276 [asan] asan_allocator2: improve FindHeapChunkByAddress to find memory chunks to the left of a given address. Almost all tests pass with the new allocator now, only 6 are left to fix.
llvm-svn: 170511
2012-12-19 08:32:50 +00:00
Kostya Serebryany bad01549b6 [asan] add some colors to asan output if printing to tty (following ubsan)
llvm-svn: 170418
2012-12-18 07:32:16 +00:00
Kostya Serebryany d6aec5a8e0 [asan] asan_allocator2: implement malloc_usable_size and fix 32-bit
llvm-svn: 170339
2012-12-17 14:57:25 +00:00
Kostya Serebryany ec339f70d6 [asan] asan_allocator2: don't use TLS and fix calloc
llvm-svn: 170329
2012-12-17 13:43:47 +00:00
Kostya Serebryany 1aae0e67fa [asan] asan_alocator2: implement quarantine and Reallocate
llvm-svn: 170315
2012-12-17 09:06:25 +00:00
Kostya Serebryany 41ffe3db59 [asan] implement AsanChunkFifoList via IntrusiveList<AsanChunk>
llvm-svn: 170313
2012-12-17 07:54:29 +00:00
Kostya Serebryany c510015419 [asan] asan_alocator2: implement free() stacks and actually make malloc/free stacks work
llvm-svn: 170310
2012-12-17 06:31:53 +00:00
Kostya Serebryany 025d64a1b9 [asan] more asan_allocator2 code: record the allocation stack trace, implement calloc/etc
llvm-svn: 170193
2012-12-14 13:16:19 +00:00
Kostya Serebryany 7dfb168eb8 [asan] more asan_allocator2 code: actually un/poison shadow on malloc/free
llvm-svn: 170190
2012-12-14 12:15:09 +00:00
Kostya Serebryany bb69879d09 [asan] pop the internal stack frames in SlowUnwindStack, extend the test to check this
llvm-svn: 170124
2012-12-13 12:31:55 +00:00
Kostya Serebryany 704c1cb23a [asan] extend overflow-in-qsort.cc to check both unwind kinds. One more test for SlowUnwind. Move both to Linux dir (no slow unwind on Mac)
llvm-svn: 170122
2012-12-13 11:47:49 +00:00
Alexey Samsonov 78ba6c1b37 [ASan] Allow leading underscore in function name to please output tests on Mac
llvm-svn: 170121
2012-12-13 11:11:28 +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 060bfab568 [asan] fix win build
llvm-svn: 170119
2012-12-13 10:03:50 +00:00
Kostya Serebryany 6852bce2f2 [asan] fix mac build
llvm-svn: 170118
2012-12-13 10:01:20 +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 5a26e1fbf2 [Sanitizer] Add new header - sanitizer_platform_interceptors.h, which should define whether or not given function should be intercepted on a given platform.
llvm-svn: 170115
2012-12-13 08:50:16 +00:00
Alexey Samsonov 447e2f2f19 [ASan] one more macro for 'read' interception
llvm-svn: 170114
2012-12-13 08:36:13 +00:00
Alexey Samsonov 65c14f5314 [ASan] more macro for conditional interception of pread functions
llvm-svn: 170112
2012-12-13 08:10:23 +00:00
Kostya Serebryany ad81738822 [asan] add asan/lit_tests/overflow-in-qsort.cc (not fully working yet)
llvm-svn: 170111
2012-12-13 08:05:03 +00:00
Kostya Serebryany 07bb3925b0 [sanitizer] replace size_t with SIZE_T in interceptors (same for ssize_t, off_t and off64_t). This is done to avoid confusion and to make the code work with compilers that define size_t w/o any includes (MSVC)
llvm-svn: 170103
2012-12-13 06:31:40 +00:00
Kostya Serebryany eec22a628b [asan] fix the Android build (pread64 interceptor again)
llvm-svn: 170098
2012-12-13 05:27:08 +00:00
Alexander Potapenko d27e4861bf [ASan] Fix test expectations for strcat/strncat.
llvm-svn: 169987
2012-12-12 16:10:46 +00:00
Kostya Serebryany e29883c10a [sanitizer] add OnMap/OnUmap callbacks to the allocator interface
llvm-svn: 169985
2012-12-12 14:32:18 +00:00
Alexander Potapenko dab1a61011 [ASan] Enhance OOB tests to check for access type (read or write).
llvm-svn: 169974
2012-12-12 12:59:47 +00:00
Alexander Potapenko 602a09fa52 [ASan] Fixed a compiler warning.
llvm-svn: 169972
2012-12-12 12:32:57 +00:00
Alexander Potapenko ada2fbd2d4 [ASan] fix compilation on Mac.
llvm-svn: 169969
2012-12-12 11:52:26 +00:00
Kostya Serebryany 28a32c89e9 [asan] fix android build and lint
llvm-svn: 169968
2012-12-12 11:37:23 +00:00
Kostya Serebryany 9a58d399c7 [asan] add sanitizer_common/sanitizer_common_interceptors.h with pread/pread64/read interceptors. Use it in asan. Add asan tests for pread/etc. Add FIXME to tsan/msan interceptors
llvm-svn: 169966
2012-12-12 09:54:35 +00:00
Kostya Serebryany 90a59fafc0 [asan] more code for asan_allocator2: basic Allocate/Deallocate code
llvm-svn: 169864
2012-12-11 14:41:31 +00:00
Timur Iskhodzhanov 4c97604415 ASan: fix lint problems introduced
llvm-svn: 169857
2012-12-11 12:24:41 +00:00
Timur Iskhodzhanov 9b1d42a2a9 Hopefully fix the Windows build (2)
llvm-svn: 169856
2012-12-11 12:23:00 +00:00
Timur Iskhodzhanov aacd3d79b1 Hopefully fix the Windows build by not including intrin.h
llvm-svn: 169855
2012-12-11 12:03:06 +00:00
Kostya Serebryany 5e2a7acdbe [asan] more sceleton code for asan_allocator2
llvm-svn: 169836
2012-12-11 09:02:36 +00:00
Kostya Serebryany 54af660d2c [asan] fix the Windows build
llvm-svn: 169828
2012-12-11 07:27:59 +00:00
Kostya Serebryany 3ba26fe553 [asan] make ThreadNamesTest more flexible
llvm-svn: 169822
2012-12-11 06:23:10 +00:00
Alexander Potapenko af5a108ea8 [ASan] Typo fix in memcpy() and memmove() interceptors: ASAN_WRITE_RANGE and ASAN_READ_RANGE were swapped.
This has been spotted by Anna Zaks (ganna@apple.com)

llvm-svn: 169736
2012-12-10 16:02:13 +00:00
Kostya Serebryany 13bdbe698e [asan] move FakeStack into a separate file
llvm-svn: 169734
2012-12-10 14:19:15 +00:00
Kostya Serebryany 14282a91d5 [asan] introduce asan_allocator2.cc, which will have the replacement for asan allocator (now, just a bit of boilerplate)
llvm-svn: 169733
2012-12-10 13:52:55 +00:00
Alexey Samsonov f0e638c6df ASan: fix interface-symbols test on Mac by explicitly listing all weak functions
llvm-svn: 169660
2012-12-08 01:12:12 +00:00
Alexey Samsonov 5aa36def74 ASan: use new option -fsanitize-blacklist in output tests
llvm-svn: 169646
2012-12-07 22:21:21 +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
Kostya Serebryany 40bac5b01f [asan] fix lint, remove debug prints
llvm-svn: 169620
2012-12-07 18:07:52 +00:00
Alexey Samsonov fa94fa52ad ASan: intercept prctl on Linux only
llvm-svn: 169616
2012-12-07 17:54:38 +00:00
Kostya Serebryany e7108227ca [asan] intercept prctl(PR_SET_NAME) and set the thread name. Output the thread names (if non-empty) in asan reports
llvm-svn: 169601
2012-12-07 15:15:01 +00:00
Kostya Serebryany 86975ce3fb [asan] drop the extension from asan tests (as the extension may be different)
llvm-svn: 169392
2012-12-05 17:56:54 +00:00
Kostya Serebryany 1a6f4d4ba6 [asan] undo the debug printf
llvm-svn: 169381
2012-12-05 13:39:29 +00:00
Kostya Serebryany 571232b8cf [tsan] get rid of *allocator64* files, moving everything to *allocator* files. This will help with the 32-bit allocator implementation and testing
llvm-svn: 169368
2012-12-05 10:09:15 +00:00
Alexander Potapenko 0dcd6d9468 [ASan] Do not build the interceptors that use ObjC blocks if the compiler does not support blocks.
Need to define MISSING_BLOCKS_SUPPORT in this case at buildtime.

Patch by Jack Howarth <howarth@bromo.med.uc.edu>
 

llvm-svn: 169206
2012-12-04 02:41:47 +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 214b715061 [asan] two more bits for __sparc__
llvm-svn: 169141
2012-12-03 18:39:21 +00:00
Kostya Serebryany a960b2c6da [asan] EXPECT_EQ => ASSERT_EQ around pthread_create/pthread_join calls
llvm-svn: 169121
2012-12-03 11:37:03 +00:00
Kostya Serebryany d5aafcf618 [asan] in asan tests, check all return values of pthread_create/pthread_join. Also add the ASAN_AVOID_EXPENSIVE_TESTS macro to guard the test that creates too many threads
llvm-svn: 169118
2012-12-03 09:43:56 +00:00
Kostya Serebryany 436462046a [asan] make asan_test.cc more gcc-friendly
llvm-svn: 168992
2012-11-30 10:41:42 +00:00
Kostya Serebryany 6a786e66cf [asan] simplify break_optimization in tests (Jakub Jelinek)
llvm-svn: 168990
2012-11-30 09:52:44 +00:00
Alexey Samsonov b90501d7da [ASan] use brand new -fsanitize= values for init-order/use-after-return ASan output tests
llvm-svn: 168951
2012-11-29 22:56:01 +00:00
Kostya Serebryany dde9dcc24b [asan] disable BuiltinLongJmpTest on Android
llvm-svn: 168872
2012-11-29 12:18:48 +00:00
Kostya Serebryany e73a480970 [asan] enable BuiltinLongJmpTest
llvm-svn: 168863
2012-11-29 09:02:14 +00:00
Kostya Serebryany df5f3028e2 [asan] add DISABLED_BuiltinLongJmpTest
llvm-svn: 168793
2012-11-28 15:01:23 +00:00
Kostya Serebryany 19e34c23c5 [asan] fix Android build by not calling GetPageSizeCached in a test (no need for the page size anyway)
llvm-svn: 168585
2012-11-26 11:23:30 +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
Alexey Samsonov 1a05424ee0 [ASan] move swapcontext_test to Linux-specific tests
llvm-svn: 168513
2012-11-23 11:20:54 +00:00
Alexey Samsonov aac36b345a [ASan] intercept swapcontext on Linux only
llvm-svn: 168509
2012-11-23 10:14:44 +00:00
Alexey Samsonov 0d7755ccb5 [ASan] Add interceptor for swapcontext to fight with false positives in some of its use cases.
llvm-svn: 168508
2012-11-23 09:46:34 +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
Kostya Serebryany 6db8ad43df [asan] pop the two internal functions from the stack trace produced by _Unwind_Backtrace (Peter Bergner)
llvm-svn: 168369
2012-11-20 15:15:44 +00:00
Kostya Serebryany 46de580003 [asan] more support for powerpc, patch by Peter Bergner
llvm-svn: 168356
2012-11-20 07:00:42 +00:00
Alexey Samsonov 27a22688b9 [ASan] use raw Exit() to kill the program in case ASan finds an error while reporting the error in the same thread
llvm-svn: 168308
2012-11-19 11:22:22 +00:00
Alexey Samsonov 06b22c1513 [ASan] change interface of GetAccumulatedStats() function to prevent Clang from inserting memcpy() call into runtime.
llvm-svn: 168305
2012-11-19 10:25:17 +00:00
Dmitry Vyukov 4ee90c231a asan: sync with gcc r193553
llvm-svn: 168151
2012-11-16 11:26:05 +00:00
Alexander Potapenko bcc00a4174 [ASan] Revert r168040 and r168043 and take a cleaner solution suggested by Kostya: return the known frame name for fake stack instead of looking it up.
llvm-svn: 168046
2012-11-15 15:24:42 +00:00
Alexander Potapenko 93dcc8d2bd [ASan] Minor fix: return to the last byte of the fake stack if we've raced by.
llvm-svn: 168043
2012-11-15 14:59:19 +00:00
Alexander Potapenko b34db9e883 [ASan] Poison the leftmost shadow byte with a special value so that we can find
the beginning of the fake frame when reporting an use-after-return error.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=126

llvm-svn: 168040
2012-11-15 13:40:44 +00:00
Alexey Samsonov 2906117857 [ASan] now we don't need llvm_obj_root to access llvm-symbolizer tool
llvm-svn: 167823
2012-11-13 07:55:16 +00:00
Alexey Samsonov c835b9e4a3 [ASan] test blacklist functionality for global-init-order checker (r167725)
llvm-svn: 167727
2012-11-12 14:03:00 +00:00
Alexander Potapenko 9448581d9e [ASan] Remove llvm-symbolizer from compiler-rt/utils/
This is the first (1/2) part of a change that moves llvm-symbolizer to llvm/tools/, which will allow to build it
with both cmake and configure+make.

llvm-svn: 167722
2012-11-12 11:32:42 +00:00
Alexander Potapenko 5066c5d9b7 [ASan] Fix the golden stack for use-after-free.cc.
The change has been caused by the switch to llvm-symbolizer, that prints inlined stack frames.
This should fix PR 14251

llvm-svn: 167721
2012-11-12 11:27:24 +00:00
Alexander Potapenko 4b8e32de12 Add a possible underscore before the wrappers to the output expectations for Darwin
llvm-svn: 167610
2012-11-09 11:55:33 +00:00
Alexey Samsonov 37119db20a [ASan] avoid including <new> header in ASan runtime
llvm-svn: 167579
2012-11-08 13:31:19 +00:00
Richard Smith 77930919ad Update compiler-rt tests to match flag renaming/deprecation in Clang.
llvm-svn: 167434
2012-11-06 02:31:42 +00:00
Alexey Samsonov 0c8b755839 Flag -ccc-clang-cxx was removed in r166986, remove it from compiler-rt lit configs
llvm-svn: 167010
2012-10-30 10:06:42 +00:00
Alexey Samsonov 23b9199776 [ASan] don't run hacky test for __asan_get_free_bytes() on 32-bits
llvm-svn: 166771
2012-10-26 12:10:24 +00:00
Alexander Potapenko 99843d3a29 In the dynamic runtime on Mac OS, do not call internal_strdup() before __asan_init().
This may result in a crash at startup.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=123.

llvm-svn: 166768
2012-10-26 11:31:14 +00:00
Alexander Potapenko 1eef2b813c [ASan] Rename ReplaceCFAllocator to MaybeReplaceCFAllocator.
Replace the allocator only if the replace_cfallocator flag is set (in some cases it wasn't checked)

llvm-svn: 166550
2012-10-24 09:35:23 +00:00
Alexander Potapenko faa9c86fd0 [ASan] Use internal_memmove() in both static and dynamic runtime libraries if asan_inited != 0.
llvm-svn: 166549
2012-10-24 09:19:16 +00:00
Alexey Samsonov cea6239219 [ASan] Due to data races, ASan malloc stats are inaccurate, which may cause certain ASan interface functions returning negative values (casted to unsigned). Return a reasonable value if such a case is detected.
llvm-svn: 166548
2012-10-24 09:19:11 +00:00
Alexey Samsonov 555d1c5ab8 [ASan] add comment to blacklist file to test behavior introduced in r166283
llvm-svn: 166284
2012-10-19 15:26:48 +00:00
Alexey Samsonov 521309294f [ASan] instrumented asan unit tests should depend on blacklist file
llvm-svn: 166282
2012-10-19 15:18:14 +00:00
Evgeniy Stepanov ad18287e56 [asan] Disable new/delete interceptors on Android and make them visible elsewhere.
llvm-svn: 166180
2012-10-18 15:22:08 +00:00
Chandler Carruth 580916eacb Re-enable this test now that r166172 has hacked around the terrible
limitations of the pass manager stack in the pass manager builder.

llvm-svn: 166173
2012-10-18 08:06:28 +00:00
Alexey Samsonov 5f1a7589ad [ASan] unit tests: Move main() to a separate file. Fix lint
llvm-svn: 166104
2012-10-17 14:04:57 +00:00
Kostya Serebryany 9ced62d195 [asan] added a test for a bug in asan at -O0 introduced by r165936 (making asan a FunctionPass). The test is not actually enabled for -O0 yet (since it fails)
llvm-svn: 166103
2012-10-17 13:42:04 +00:00
Alexey Samsonov 7b52cb9e6d [ASan] Fix strchr/index tests for users who have 'char* strchr(char*,int)' instead of 'char* strchr(const char*, int)'
llvm-svn: 166101
2012-10-17 13:39:09 +00:00
Alexey Samsonov 4230a4a05a [ASan] don't use attribute no_address_safety_analysis if it's unknown to compiler
llvm-svn: 166099
2012-10-17 13:19:59 +00:00
Kostya Serebryany 05a3b01d4f [asan] fix gcc warnings while building asan-rt
llvm-svn: 166093
2012-10-17 08:50:53 +00:00
Alexander Potapenko e3e80d607f Do not call ReplaceCFAllocator() before __CFInitialize(), otherwise crashes are possible on 10.8.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=122

llvm-svn: 166029
2012-10-16 16:58:10 +00:00