Commit Graph

2364 Commits

Author SHA1 Message Date
Dmitry Vyukov c63d73e59d tsan: support heap starting at 0x04c0 (used in some custom deplyments)
llvm-svn: 180116
2013-04-23 15:59:56 +00:00
Dmitry Vyukov 43cf90f4d1 tsan: update Go memory mapping, Go now uses 0x00c0 heap base
llvm-svn: 180113
2013-04-23 15:24:26 +00:00
Evgeniy Stepanov 44b75efab4 [sanitizer] Intercept inet_pton and inet_ntop.
llvm-svn: 180107
2013-04-23 14:05:15 +00:00
Alexey Samsonov bcd32a9525 [ASan] Disable strict-init-order checker once we have more than one thread, as this mode is thread-hostile
llvm-svn: 180106
2013-04-23 13:57:35 +00:00
Alexey Samsonov 34093f0de8 [MSan] Make a few interface functions accept 'const void *' instead of 'void*'
llvm-svn: 180102
2013-04-23 13:34:19 +00:00
Evgeniy Stepanov 455abf4872 [msan] Unpoison the result of posix_memalign.
llvm-svn: 180101
2013-04-23 13:27:36 +00:00
Alexey Samsonov f36c5a8431 Revert r180082 and add a test for SetEnv function
llvm-svn: 180098
2013-04-23 12:49:12 +00:00
Alexander Potapenko 262eb01bbf [ASan] Make wait.cc more Darwin-compatible: fix the header name and the CHECK patterns.
llvm-svn: 180097
2013-04-23 12:36:37 +00:00
Alexander Potapenko 15aa1cd1ac [ASan] Disable AddressSanitizer.AllocDeallocMismatch on Darwin.
See https://code.google.com/p/address-sanitizer/issues/detail?id=131.

llvm-svn: 180093
2013-04-23 12:14:55 +00:00
Evgeniy Stepanov 3076ba0a08 [sanitizer] Intercept getgrnam{_r}, getgrgid{_r}.
llvm-svn: 180091
2013-04-23 12:01:20 +00:00
Evgeniy Stepanov 0cd7cf8217 [msan] Allow clock_getres(, 0).
llvm-svn: 180090
2013-04-23 11:48:31 +00:00
Alexey Samsonov e7540e3561 [Sanitizer] Delete unused function
llvm-svn: 180082
2013-04-23 08:18:09 +00:00
Evgeniy Stepanov 1a2262e1c9 [sanitizer] Fix lint.
llvm-svn: 180012
2013-04-22 13:28:26 +00:00
Bill Wendling 9a9141aed5 Improve performance of file I/O.
The fread / fwrite calls were happening for each timer. However, that could be
pretty expensive for a large number of timers. Instead, read and write the
timers in one call.

This gives ~10% speedup in compilation time.

llvm-svn: 179990
2013-04-22 03:36:22 +00:00
Alexey Samsonov e7ea8cfb49 Fixup for r179843: add missing header
llvm-svn: 179844
2013-04-19 08:49:05 +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
Alexey Samsonov 6021e94774 [TSan] Allocate fd table in user heap instead of using internal allocator. We need this to catch races on fds.
llvm-svn: 179841
2013-04-19 08:04:46 +00:00
Alexey Samsonov 1a6cfb46e5 [Sanitizer] Rework r176802: share code between Printf and Report and simplify it a bit
llvm-svn: 179755
2013-04-18 13:18:23 +00:00
Alexey Samsonov d1efa5ef96 [Sanitizer] Don't die in symbolizer if it can't read /proc/self/exe link
llvm-svn: 179754
2013-04-18 12:46:33 +00:00
Andy Gibbs f6edda8c30 Wrap macro invocations in braces to supress 'suggest braces around empty body in an ‘if’ statement' warning.
llvm-svn: 179597
2013-04-16 15:18:55 +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
Evgeniy Stepanov d1dae90bf2 [msan] Fix gcc build of msan_test.
llvm-svn: 179594
2013-04-16 14:09:47 +00:00
Evgeniy Stepanov 9b59a39f42 [sanitizer] Implement wait4 and waitpid syscall hooks.
llvm-svn: 179592
2013-04-16 13:06:20 +00:00
Evgeniy Stepanov b0d786798c [msan] Fix sigaction test.
Restore SIGPROF handler to the original state after the test.

llvm-svn: 179524
2013-04-15 13:35:05 +00:00
Evgeniy Stepanov 7332acac4c [msan] Really disable replacement new and delete.
llvm-svn: 179522
2013-04-15 12:41:52 +00:00
Evgeniy Stepanov 755eb32a39 [sanitizer] Add syscall handlers to ASan and TSan runtimes.
ASan checks addressability of syscall arguments. TSan does nothing for now.

llvm-svn: 179380
2013-04-12 14:57:03 +00:00
Evgeniy Stepanov 9fb82357dc [sanitizer] More syscall handler placeholders.
This time it's the full list scavenged from syscalls.h
Fixed return value type.

llvm-svn: 179378
2013-04-12 14:06:40 +00:00
Timur Iskhodzhanov 664ec5d7a8 Finally drop the 'static' from INLINE and ALWAYS_INLINE
The ALWAYS_INLINE doesn't have static on POSIX anyways since r178341; the INLINE is only used in .h files, so shouldn't have been 'static' in the first place

llvm-svn: 179371
2013-04-12 09:37:20 +00:00
Alexey Samsonov e48866969e [MSan] Demangle function name in description of stack origin
llvm-svn: 179368
2013-04-12 07:27:30 +00:00
Alexey Samsonov 1a345ad502 [MSan] don't build tests with -fPIE/-pie, as these flags are implied by -fsanitize=memory now
llvm-svn: 179366
2013-04-12 07:14:04 +00:00
Alexey Samsonov 0d725b1408 [TSan] remove -fPIE -pie from TSan lit tests to check that -fsanitize=thread implies them now
llvm-svn: 179365
2013-04-12 07:11:00 +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 bb68f2cd65 [asan] make heavy_uar_test even heavier
llvm-svn: 179306
2013-04-11 18:27:02 +00:00
Alexey Samsonov 9f3938e271 Explicitly list all sanitizer headers in CMake build rules. Make sure sanitizer lit_tests depend on fresh headers.
llvm-svn: 179293
2013-04-11 15:49:52 +00:00
Kostya Serebryany 1c77de3aeb [asan] improve the UAR reporting (try harder to find the correct frame), try to make the test more stable
llvm-svn: 179292
2013-04-11 15:35:40 +00:00
Evgeniy Stepanov f5523116e9 [sanitizer] Syscall hooks.
Pre- and post- hooks for linux syscalls. Not wired into anything, but exposed
through public interface.

llvm-svn: 179288
2013-04-11 14:37:04 +00:00
Kostya Serebryany 18f0820552 [asan] make heavy_uar_test a bit more heavy and fix he fake stack to pass this test
llvm-svn: 179286
2013-04-11 14:07:02 +00:00
Alexey Samsonov a672ba6e8f [ASan] test source-based init-order blacklisting added in r179280
llvm-svn: 179281
2013-04-11 13:21:41 +00:00
Kostya Serebryany 3fec2f534a [asan] fix use-after-return functionality (PR15672) and enable the corresponding test. We still don't guarantee anything with regard to use-after-return checking
llvm-svn: 179278
2013-04-11 12:49:38 +00:00
Alexey Samsonov 46cc45a291 [ASan] Symbolize correct address when printint error summary
llvm-svn: 179274
2013-04-11 11:45:04 +00:00
Kostya Serebryany 4e0a33c8be [asan] move fake stack into a separate .h file; actually disable a failing test
llvm-svn: 179273
2013-04-11 11:39:19 +00:00
Kostya Serebryany fd7f924016 [asan] add heavy_uar_test (disabled); fix lint
llvm-svn: 179271
2013-04-11 11:29:07 +00:00
Alexander Potapenko 227e22de5a [ASan] Do not check the shadow of NULL argument in the time() interceptor.
Add a test for time().

llvm-svn: 179177
2013-04-10 15:13:00 +00:00
Kostya Serebryany 92684efb1d [asan] implement callbacks for unaligned loads/stores
Reviewers: samsonov

Reviewed By: samsonov

CC: samsonov, llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D652

llvm-svn: 179175
2013-04-10 13:59:32 +00:00
Alexey Samsonov c0443c5d25 [ASan] fix a typo in legend in error report
llvm-svn: 179161
2013-04-10 07:00:25 +00:00
Evgeniy Stepanov 460067823b [sanitizer] Interceptors for wait*.
llvm-svn: 179096
2013-04-09 14:34:59 +00:00
Evgeniy Stepanov 69967c2835 [msan] Intercept glob() with tests.
llvm-svn: 179091
2013-04-09 11:35:13 +00:00
Alexey Samsonov 7ad129277e [Sanitizer] fix TSan tests: remove global ctor from sanitizer_common, run load_shared_lib test only in lit
llvm-svn: 179090
2013-04-09 07:46:20 +00:00
Kostya Serebryany 9d28efc1ad [asan] relax Linux/zero-base-shadow.cc to make it pass on newer Ubuntu; fix lint
llvm-svn: 179088
2013-04-09 07:08:05 +00:00
Chandler Carruth 2b3c00eec7 Revert r179012: "[msan] Intercept glob()."
This was committed without tests and contains obvious bugs. That's not
acceptable. It broke address sanitizer for most programs using glob(3).

llvm-svn: 179054
2013-04-08 20:59:44 +00:00
Alexander Potapenko 32efd25b93 [libsymbolized] If we can't find an address in the list of shared libraries, try to reload it.
Add a regression test for the case where such behavior helps TSan:
  1. race is reported in the main module
  2. new shared library is loaded
  3. race is reported in the shared library

llvm-svn: 179032
2013-04-08 17:46:34 +00:00
Evgeniy Stepanov b4eac2f810 [msan] Interceptors for pipe2 and socketpair.
llvm-svn: 179022
2013-04-08 13:45:12 +00:00
Evgeniy Stepanov 8cd707a1a6 [msan] Intercept glob().
llvm-svn: 179012
2013-04-08 09:03:00 +00:00
Evgeniy Stepanov e20c780aaf [tsan] Fix build.
llvm-svn: 179008
2013-04-08 08:46:25 +00:00
Kostya Serebryany e6459977b8 [sanitizer] Fix boundary condition in LargeMmapAllocator::GetBlockBegin. Patch by Sergey Matveev
llvm-svn: 179007
2013-04-08 08:43:22 +00:00
Evgeniy Stepanov 7ba7207f1d [msan] Intercept time().
llvm-svn: 179002
2013-04-08 08:25:22 +00:00
Kostya Serebryany 228ecf46ab [asan] make huge_negative_hea_oob more meaningful
llvm-svn: 178876
2013-04-05 15:16:48 +00:00
Kostya Serebryany f5407e8d8f [asan] add a test for huge left oob
llvm-svn: 178874
2013-04-05 15:13:23 +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
Evgeniy Stepanov e7a7a9b972 [msan] Fix sigaction interceptor.
llvm-svn: 178868
2013-04-05 12:58:07 +00:00
Evgeniy Stepanov c7af878a01 [msan] Conditionally disable new() and delete() wrappers.
To be used with static libstdc++.

llvm-svn: 178866
2013-04-05 12:03:47 +00:00
Evgeniy Stepanov 7948c648bf [msan] A runtime option to disable wrapping of signal handlers.
llvm-svn: 178865
2013-04-05 11:59:16 +00:00
Alexey Samsonov 2a4668557f [Sanitizer] enquote the module name when passing it to external symbolizer
llvm-svn: 178864
2013-04-05 11:54:23 +00:00
Alexey Samsonov 5afe6aa141 [ASan] init-order checker tests: move constexpr test that requires -std=c++11 to a separate test case. Check that structs with no ctor but non-trivial dtor are ignored.
llvm-svn: 178857
2013-04-05 07:51:49 +00:00
Alexey Samsonov 46b8665ea4 Remove InternalAlloc/InternalFree calls from StopTheWorld. Patch by Sergey Matveev.
llvm-svn: 178855
2013-04-05 07:41:21 +00:00
Alexey Samsonov 734aab4066 [Sanitizer] Use a common mutex to prevent mixing reports from different sanitizers. This fixes PR15516
llvm-svn: 178853
2013-04-05 07:30:29 +00:00
Alexey Samsonov 70a9c263d4 [TSan] Make path to FileCheck configurable
llvm-svn: 178760
2013-04-04 12:18:12 +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
Evgeniy Stepanov 24b2169e07 [sanitizer] Android lacks ucontext_t definition.
llvm-svn: 178756
2013-04-04 09:21:48 +00:00
Evgeniy Stepanov 7b0e132551 [sanitizer] Use ucontext_t instead of "struct ucontext".
Fixes Mac build.

llvm-svn: 178755
2013-04-04 09:03:56 +00:00
Evgeniy Stepanov 1f8b3538b4 [msan] Unpoison siginfo_t and ucontext_t in signal handlers.
Add wrappers for all user signal handlers to unpoison the handler's arguments.

llvm-svn: 178754
2013-04-04 08:22:52 +00:00
Kostya Serebryany c3525ce6ac [sanitizer] while doing fast unwinding make sure that the frame pointer is aligned; fix lint
llvm-svn: 178747
2013-04-04 06:52:40 +00:00
Alexey Samsonov 87c2a87b50 [Sanitizer] Fix OnPrint weak hook. Disable weak hooks for gotsan.
llvm-svn: 178640
2013-04-03 13:22:54 +00:00
Alexey Samsonov 60adc1781e [Sanitizer] Be more careful with arch-specific defines in StopTheWorld code
llvm-svn: 178630
2013-04-03 08:26:03 +00:00
Alexey Samsonov 21cb74318c [ASan] Kill the remainders of platform defines in favor of SANITIZER_ defines
llvm-svn: 178629
2013-04-03 07:29:53 +00:00
Alexey Samsonov a0e28a7aaa [Sanitizer] Kill the remainders of platform defines in favor of SANITIZER_ defines
llvm-svn: 178627
2013-04-03 07:24:35 +00:00
Alexey Samsonov 8d18cc3096 [Sanitizer] Fix StopTheWorld includes on Android. Patch by Sergey Matveev.
llvm-svn: 178625
2013-04-03 07:06:10 +00:00
Alexander Potapenko bbfc722e46 [TSan] Add the WTFAnnotateBenignRaceSized implementation and a test for
WTFAnnotateBenignRaceSized and AnnotateBenignRaceSized.

llvm-svn: 178534
2013-04-02 11:21:53 +00:00
Evgeniy Stepanov f8213b4eb3 [sanitizer] More interceptors.
getpwnam, getpwuid, getpwnam_r, getpwuid_r, clock_getres, clock_gettime,
clock_settime, getitimer, setitimer, sigaction (MSan).

llvm-svn: 178465
2013-04-01 14:47:21 +00:00
Alexander Potapenko 1d021bff28 [libsanitizer] Run the callback on a separate stack in StopTheWorld.
Currently the callback runs on the caller's stack. If this stack
contains values that have gone out of scope, and we are not super careful, those
values can propagate into global variables (the libc sigaction() in particular
has a side effect that can lead to this). This has caused false negatives in
leak checking code.

Changes: map a separate stack space for the tracer thread. Also, move some
globals into local scope (they had no business being global anyway).

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178464
2013-04-01 14:38:56 +00:00
Alexander Potapenko 401bed0b9a [libsanitizer] Added data() and capacity() getters to InternalVector.
Same interface as in STL. Needed for LSan.

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178463
2013-04-01 13:55:34 +00:00
Alexander Potapenko 9cc2e436bb [libsanitizer] Add register dumping support to SuspendedThreadsList.
An interface for obtaining register contexts from suspended threads. Tailored
for LSan use.

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178461
2013-04-01 13:36:42 +00:00
Alexey Samsonov e624795558 [ASan] More careful reports for globals that are ASCII strings
llvm-svn: 178458
2013-04-01 08:57:38 +00:00
Michael Gottesman 4ddc2156d6 Change the cmake variable COMPILER_RT_CAN_EXECUTE_TESTS to be an option so that it can overwritten.
The reason why this simple change is needed is that I am trying to set up a
quick cmake/ninja based buildbot and apple-clang does not support using the
sanitizers currently.

The default behavior follows exactly what was there before implying that no ones
builds should be affected at all.

llvm-svn: 178455
2013-04-01 04:13:03 +00:00
Kostya Serebryany 91952cda76 [tsan] restore performance critical inlining in tsan: remove static from ALWAYS_INLINE, use ALWAYS_INLINE USED for critical functions.
llvm-svn: 178341
2013-03-29 09:44:16 +00:00
Alexander Potapenko b042555cd3 [TSan] Build TSan runtime with -fPIE.
This removes all register spills from the performance-critical __tsan_{read,write}{1,2,4,8} functions when the host compiler is GCC.

llvm-svn: 178340
2013-03-29 09:44:11 +00:00
Alexander Potapenko 389b45061f [libsanitizer] Put COMMON_CFLAGS/COMMON_CXXFLAGS before Tmp.CFLAGS to let the config-specific flags override common flags.
llvm-svn: 178339
2013-03-29 09:41:10 +00:00
Alexey Samsonov 703a9870a2 [Sanitizer] Follow-up for r178238 - replace DCHECKs with regular CHECKs
llvm-svn: 178336
2013-03-29 08:03:01 +00:00
Timur Iskhodzhanov 23411d9a95 Band-aid fix for the TSan RTL build
llvm-svn: 178298
2013-03-28 22:23:03 +00:00
Timur Iskhodzhanov e3164e9647 Add "static" to the Windows ALWAYS_INLINE macro (similar to what we do on POSIX)
llvm-svn: 178296
2013-03-28 22:07:28 +00:00
Timur Iskhodzhanov 07d06d7cf5 Remove all 'static' before ALWAYS_INLINE
llvm-svn: 178290
2013-03-28 21:16:09 +00:00
Timur Iskhodzhanov a6788325cf Make all the ALWAYS_INLINE users Windows-friendly; also, avoid ALWAYS_INLINE INLINE combinations
llvm-svn: 178266
2013-03-28 18:52:40 +00:00
Dmitry Vyukov f2cbda4082 tsan: print statistics about benign race annotations
(total count, unique, matched) if requested with print_benign=1
flag.

llvm-svn: 178245
2013-03-28 16:21:19 +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 cfe56d47da [Sanitizer] Minor enhancements in InternalVector container
llvm-svn: 178238
2013-03-28 15:37:11 +00:00
Kostya Serebryany 3e73c84050 [tsan] a test checking that memset/memcpy/memmove are not inlined in tsan mode
llvm-svn: 178231
2013-03-28 11:21:50 +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
Kostya Serebryany ac83282665 [tsan] don't use -fno-builtin for tests; add a test for a false negative bug (inlined memcpy is not instrumented)
llvm-svn: 178228
2013-03-28 08:41:49 +00:00
Richard Smith 74e3d39710 compiler-rt part of r178194. Remove ubsan test for diagnostic on inf/nan conversion between floating-point types.
llvm-svn: 178195
2013-03-27 23:21:10 +00:00
Dmitry Vyukov b365d40415 tsan: print matched suppressions if print_suppressions=1 flag is provided
llvm-svn: 178159
2013-03-27 17:59:57 +00:00
Dmitry Vyukov fd3f5ec0cb tsan: better flag parsing: do not confuse flag that is a part of another flag
(e.g. suppressions and print_suppressions)

llvm-svn: 178158
2013-03-27 17:59:13 +00:00
Dmitry Vyukov 9f08fe5065 tsan: fix lint warning
llvm-svn: 178157
2013-03-27 17:57:58 +00:00
Alexey Samsonov 7152debedd [ASan] Demangle global names in error reports.
llvm-svn: 178131
2013-03-27 10:41:22 +00:00
Alexey Samsonov f903a9ee6e [TSan] Fixup for r178128: verify that TSan indeed doesn't report race
llvm-svn: 178129
2013-03-27 10:22:51 +00:00
Alexey Samsonov 059e61f8b0 [TSan] Run test output through FileCheck
llvm-svn: 178128
2013-03-27 09:25:06 +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
Alexander Potapenko 29310ba077 [libsanitizer] Fix the Win build.
llvm-svn: 178012
2013-03-26 13:02:11 +00:00
Kostya Serebryany 79a6e189b0 [tsan] make memcpy_race.cc test immune to memcpy inlining
llvm-svn: 178011
2013-03-26 12:42:18 +00:00
Dmitry Vyukov 6f4b34bcf4 asan/tsan: move strcasecmp() interceptor to sanitizer_common
llvm-svn: 178010
2013-03-26 12:40:23 +00:00
Dmitry Vyukov f3bc56bb6b asan/tsan: change SANITIZER_GO to more general SANITIZER_SUPPORTS_WEAK_HOOKS
llvm-svn: 178009
2013-03-26 12:07:04 +00:00
Alexander Potapenko f8109dd0f8 [libsanitizer] Unmapping the old cache partially invalidates the memory layout, so add
a flag to skip cache update for cases when that's unacceptable (e.g. lsan).

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178000
2013-03-26 10:34:37 +00:00
Alexey Samsonov 7ef76c1cd8 [Sanitizer] Disable atomic_test on Android, where it crashes Clang.
llvm-svn: 177998
2013-03-26 08:55:38 +00:00
Kostya Serebryany 4d7efba66e [tsan] add a test for aligned-vs-unaligned race (tsan's false negative)
llvm-svn: 177996
2013-03-26 08:31:02 +00:00
Kostya Serebryany 88b2b45ec8 [asan] print thread number while reporting invalid-free and double-free; add tests; also add a test for use-after-poison
llvm-svn: 177993
2013-03-26 08:01:37 +00:00
Timur Iskhodzhanov 2dee3dd61c Add a GetTid() implementation for Windows
llvm-svn: 177927
2013-03-25 22:04:29 +00:00
Alexey Samsonov 6210e1f9ff Add basic support for building profile compiler-rt library in CMake build on Darwin
llvm-svn: 177870
2013-03-25 14:20:11 +00:00
Alexey Samsonov 961b636cf1 [ASan] Use dynamic symbol table when checking exported ASan runtime symbols
llvm-svn: 177868
2013-03-25 13:47:53 +00:00
Dmitry Vyukov 7886253fee asan/tsan: add Printf/Report hook
The hook can be overriden in frontend to print to e.g. a file.

llvm-svn: 177864
2013-03-25 12:58:09 +00:00
Alexey Samsonov 9328ba400a [ASan] mark local function as static
llvm-svn: 177862
2013-03-25 11:38:42 +00:00
Alexey Samsonov acfb82e611 [Sanitizer] Compile sanitizer runtimes with -Wno-non-virtual-dtor. Virtual dtors may be a problem for us, as sanitizer runtime should not generally assume libstdc++ presence.
llvm-svn: 177860
2013-03-25 10:31:49 +00:00
Alexey Samsonov 31a2c483ed [TSan] Build TSan unit tests with the same compile flags as TSan runtime
llvm-svn: 177859
2013-03-25 10:23:20 +00:00
Dmitry Vyukov 4adf49d253 tsan: intercept setjmp/longjmp
llvm-svn: 177858
2013-03-25 10:10:44 +00:00
Dmitry Vyukov 510ad11800 tsan: add SetEnv() function that can be used in frontends
llvm-svn: 177857
2013-03-25 09:56:45 +00:00
Alexey Samsonov a208c397bf [Sanitizer] First effort to implement atomic_compare_exchange for 1-byte vars on Windows
llvm-svn: 177854
2013-03-25 09:23:30 +00:00
Alexey Samsonov c6fd019c77 [Sanitizer] Add basic test for atomic_compare_exchange implementation
llvm-svn: 177851
2013-03-25 08:48:16 +00:00
Richard Smith c91e327cba Build and install .syms files alongside sanitizer runtimes. These are used to
specify which symbols are exported to DSOs when the sanitizer is statically
linked into a binary.

llvm-svn: 177784
2013-03-23 00:31:07 +00:00
Timur Iskhodzhanov fb74020cea Revert 177745 as it was incorrect
llvm-svn: 177746
2013-03-22 18:16:57 +00:00
Timur Iskhodzhanov e117eef77f Band-aid fix for the Windows build caused by r177710. Long-term, atomic_compare_exchange_strong should be a template on Windows too...
llvm-svn: 177745
2013-03-22 18:05:28 +00:00
Dmitry Vyukov 9af68719ed tsan: return 0 on malloc() failure instead of crashing
llvm-svn: 177741
2013-03-22 17:06:22 +00:00
Evgeniy Stepanov ecbf64648f [msan] Handle dlopen() failure in dlopen interceptor.
llvm-svn: 177728
2013-03-22 11:59:49 +00:00
Dmitry Vyukov 3bd5ffb62b tsan: test that tsan explicitly says "race on vptr".
Requires llvm r177717.

llvm-svn: 177726
2013-03-22 10:54:39 +00:00
Kostya Serebryany 667a34a120 [asan] Change the way we report the alloca frame on stack-buff-overflow.
Before: the function name was stored by the compiler as a constant string
and the run-time was printing it.
Now: the PC is stored instead and the run-time prints the full symbolized frame.
This adds a couple of instructions into every function with non-empty stack frame,
but also reduces the binary size because we store less strings (I saw 2% size reduction).
This change bumps the asan ABI version to v3.

compiler-rt part, llvm part will follow.

Example of report (now):
==31711==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffa77cf1c5 at pc 0x41feb0 bp 0x7fffa77cefb0 sp 0x7fffa77cefa8
READ of size 1 at 0x7fffa77cf1c5 thread T0
    #0 0x41feaf in Frame0(int, char*, char*, char*) stack-oob-frames.cc:20
    #1 0x41f7ff in Frame1(int, char*, char*) stack-oob-frames.cc:24
    #2 0x41f477 in Frame2(int, char*) stack-oob-frames.cc:28
    #3 0x41f194 in Frame3(int) stack-oob-frames.cc:32
    #4 0x41eee0 in main stack-oob-frames.cc:38
    #5 0x7f0c5566f76c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)
    #6 0x41eb1c (/usr/local/google/kcc/llvm_cmake/a.out+0x41eb1c)
Address 0x7fffa77cf1c5 is located in stack of thread T0 at offset 293 in frame
    #0 0x41f87f in Frame0(int, char*, char*, char*) stack-oob-frames.cc:12  <<<<<<<<<<<<<< this is new
  This frame has 6 object(s):
    [32, 36) 'frame.addr'
    [96, 104) 'a.addr'
    [160, 168) 'b.addr'
    [224, 232) 'c.addr'
    [288, 292) 's'
    [352, 360) 'd'

llvm-svn: 177723
2013-03-22 10:36:24 +00:00
Evgeniy Stepanov 93a842bd1f [msan] Move test main and gtest include to separate files.
llvm-svn: 177718
2013-03-22 09:01:26 +00:00
Evgeniy Stepanov bfe9df221d [msan] Place dlopen in an anon namespace.
llvm-svn: 177716
2013-03-22 08:49:36 +00:00
Dmitry Vyukov 2f411641fe tsan: work around FileCheck bug with empty outputs
llvm-svn: 177715
2013-03-22 08:48:34 +00:00
Evgeniy Stepanov 5d69168906 [msan] Get rid of "using std::string" in msandr.
llvm-svn: 177714
2013-03-22 08:47:42 +00:00
Alexey Samsonov f1311dfce1 [ASan] fix-up for r177634 on Windows.
llvm-svn: 177711
2013-03-22 07:48:23 +00:00
Alexey Samsonov a5eb3cb721 [ASan] Fix an error on invalid deallocation in ASan allocator. When ASan checks if memory freed by user was indeed previously allocated, it first does an atomic write to presumed location of chunk header. This is wrong, as if the free is invalid, we may overwrite some valuable data (like other fields of the chunk header). Fix this by using atomic_compare_exchange instead.
llvm-svn: 177710
2013-03-22 07:40:34 +00:00
Dmitry Vyukov a7e42b5be5 asan: fix lint warning about line length
llvm-svn: 177709
2013-03-22 07:29:59 +00:00
Richard Smith b30d11194c ubsan: Pass floating-point arguments to the runtime by value if they fit the
value argument.

llvm-svn: 177689
2013-03-22 00:47:05 +00:00
Richard Smith 1ea5b805ce Don't forget to link in the C++-specific parts of the ubsan runtime when using the Makefile build system on Darwin.
llvm-svn: 177684
2013-03-22 00:01:44 +00:00
Dmitry Vyukov ebf63d0095 tsan: better reporting of thread leaks
1. do not report running threads as leaks
2. aggregate leaked threads by creation stack

llvm-svn: 177647
2013-03-21 16:55:17 +00:00
Dmitry Vyukov 0851fa8819 tsan: better reporting for races on vptr
explicitly say "ctor/dtor vs virtual call"

llvm-svn: 177640
2013-03-21 15:37:39 +00:00
Dmitry Vyukov 2c3b919ad3 tsan: add flag to control symbolizer flush frequency
llvm-svn: 177638
2013-03-21 13:01:50 +00:00
Dmitry Vyukov 69c323d66f tsan: intercept abort() to fflush() libc streams
llvm-svn: 177637
2013-03-21 12:50:43 +00:00
Dmitry Vyukov 6911a7f1d1 tsan: remove bogus CHECK
Asynchronous signal (e.g. SIGABRT) can be received with any value of in_rtl.

llvm-svn: 177636
2013-03-21 12:44:44 +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
Dmitry Vyukov 48e5d4a2d3 tsan: flush symbolizer cache if not symbolized for more than 5 seconds
llvm-svn: 177629
2013-03-21 07:02:36 +00:00
Dmitry Vyukov 5e797a8e57 tsan: add a comment about magic numbers
llvm-svn: 177628
2013-03-21 06:28:04 +00:00
Dmitry Vyukov 78693730a4 tsan: use a single background thread for memory profiler and memory flush (and later for symbolizer flush)
llvm-svn: 177627
2013-03-21 06:24:31 +00:00
Richard Smith b6f3905450 Per discussion on cxx-abi-dev, switch from comparing type_info objects to
comparing type_info names, since the latter have better uniqueness guarantees
in practice.

llvm-svn: 177618
2013-03-21 00:42:03 +00:00
Richard Smith e86b7b0bb9 Split ubsan runtime into three pieces (compiler-rt part):
* libclang_rt-san-* is sanitizer_common, and is linked in only if no other
   sanitizer runtime is present.
 * libclang_rt-ubsan-* is the piece of the runtime which doesn't depend on
   a C++ ABI library, and is always linked in.
 * libclang_rt-ubsan_cxx-* is the piece of the runtime which depends on a
   C++ ABI library, and is only linked in when linking a C++ binary.

The Darwin ubsan runtime is unchanged.

For more details, see Clang change r177605.

llvm-svn: 177606
2013-03-20 23:49:17 +00:00
Bill Wendling 7184d34f96 Add declaration for linux.
llvm-svn: 177601
2013-03-20 23:21:08 +00:00
Bill Wendling 51a6ff5799 Create a coverage initialization function.
This function replaces the call of `atexit' from being generated in the compile
units. Basically, it registers the "writeout" and "flush" functions (if
present). It will generate calls to the `atexit' function for cleanups and final
writeout functions, but only once. This is better than checking for `main',
because a library may not have a `main' function in it.
<rdar://problem/12439551>

llvm-svn: 177578
2013-03-20 21:11:47 +00:00
Dmitry Vyukov 6120bac6e6 tsan: correct sizes of signal-related data structures
llvm-svn: 177526
2013-03-20 14:57:28 +00:00
Dmitry Vyukov 9f94dff7a6 tsan: add missing stat descriptions
llvm-svn: 177523
2013-03-20 14:04:23 +00:00
Dmitry Vyukov 0954e9c01d tsan: call fflush(0) on exit again
llvm-svn: 177522
2013-03-20 14:01:10 +00:00
Dmitry Vyukov c638a7127e tsan: reduce size of mutexsets from 64 to 16 mutexes
overflow is handled anyway
saves memory because each thread holds 1024 mutexsets

llvm-svn: 177520
2013-03-20 13:50:47 +00:00
Dmitry Vyukov 3330200d92 tsan: fix incorrect test
llvm-svn: 177519
2013-03-20 13:49:45 +00:00
Dmitry Vyukov b62c158d81 tsan: special handling of .rodata (don't try to find races, don't keep shadow, dont' put into traces)
llvm-svn: 177517
2013-03-20 13:21:50 +00:00
Dmitry Vyukov ccbdea956f tsan: fix build
llvm-svn: 177513
2013-03-20 11:22:03 +00:00
Dmitry Vyukov 79915de6af tsan: move trace header into 0x600000000000 range
eliminat thread "dead info" altogether

llvm-svn: 177512
2013-03-20 10:31:53 +00:00
Dmitry Vyukov b6eace8a2f tsan: add internal_unlink() function
llvm-svn: 177510
2013-03-20 10:28:36 +00:00
Alexey Samsonov 920b3b9a0c [ASan] Move malloc stats collection away from AsanThreadRegistry class.
llvm-svn: 177508
2013-03-20 10:11:24 +00:00
Dmitry Vyukov 31056968fc asan/tsan: reduce per-thread memory allocator caches
256 blocks (which is 512 in reallity) seems to be too big cache,
reducing the size reduces memory consumption but does not degrade performance.

llvm-svn: 177502
2013-03-20 09:26:46 +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
Dmitry Vyukov b7c68ee856 tsan: fix flaky test
llvm-svn: 177500
2013-03-20 09:22:13 +00:00
Dmitry Vyukov f6c4a7a2f5 tsan: fix incorrect test
llvm-svn: 177499
2013-03-20 09:21:49 +00:00
Evgeniy Stepanov 52b2d13245 [sanitizer] Enable prctl interceptor on Android.
llvm-svn: 177497
2013-03-20 07:35:52 +00:00
Bill Wendling e647659d58 Add a way to register and execute "writeout" functions.
It may be prohibitively expensive to write out >1000 files at the same time. So
we would rather emit them serially. These functions allow the GCOV
implementation to register the functions that writeout the GCOV information per
compile unit. At exit, they are written.
<rdar://problem/12439551>

llvm-svn: 177436
2013-03-19 21:01:19 +00:00
Evgeniy Stepanov 9a8f0f55d5 [asan] s/ASAN_POSIX/SANITIZER_POSIX/
llvm-svn: 177407
2013-03-19 15:26:41 +00:00
Evgeniy Stepanov 95eaa21637 [sanitizer] More renamed macros.
llvm-svn: 177401
2013-03-19 14:54:17 +00:00
Evgeniy Stepanov 0af672326a [sanitizer] Replace more platform checks with SANITIZER_ constants.
llvm-svn: 177400
2013-03-19 14:33:38 +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 45d2f96582 Don't use --sysroot to linux SDK when building libprofile - SDK on Linux seems to be incomplete.
llvm-svn: 177396
2013-03-19 13:34:23 +00:00
Dmitry Vyukov 082afc8346 tsan: fix build
llvm-svn: 177395
2013-03-19 13:34:12 +00:00
Dmitry Vyukov 4ecfa696e0 tsan: flush dead thread info earlier (when another thread is finished rather than new thread is created)
llvm-svn: 177394
2013-03-19 12:25:48 +00:00
Dmitry Vyukov 9dd06ad47a tsan: instruct malloc() to consume less memory
llvm-svn: 177393
2013-03-19 12:24:19 +00:00
Dmitry Vyukov f3fde82667 tsan: symbolizer "flush caches" support
llvm-svn: 177389
2013-03-19 10:24:01 +00:00
Dmitry Vyukov 29f335ae80 tsan: symbolizer "flush caches" functinality
llvm-svn: 177388
2013-03-19 10:23:17 +00:00
Dmitry Vyukov 509dab30ae tsan: fix memory leak
llvm-svn: 177387
2013-03-19 10:22:33 +00:00
Evgeniy Stepanov 6d02c1c598 [sanitizer] Avoid use of uintptr_t.
llvm-svn: 177384
2013-03-19 09:39:15 +00:00
Evgeniy Stepanov b4a218db34 [sanitizer] Don't adjust the size of the user-allocated stack.
Moved this code to sanitizer_common.

llvm-svn: 177383
2013-03-19 09:30:52 +00:00
Alexey Samsonov 4c17c1b157 Support CMake build of profile runtime library on Linux
llvm-svn: 177382
2013-03-19 09:17:35 +00:00
Dmitry Vyukov b59fa875ad tsan: do not allocate sync vars on relaxed atomic operations
helps to reduce memory consumption if an atomic is used only with relaxed ops (stats)

llvm-svn: 177381
2013-03-19 09:15:31 +00:00
Richard Smith 807e4dced5 Update ubsan test for clang change r177362.
llvm-svn: 177363
2013-03-19 00:04:20 +00:00
Bill Wendling 2428f167f7 Add some GCOV functions that register all of the __llvm_gcov_flush() functions.
The __llvm_gcov_flush() functions only work for the local compile unit. However,
when __gcov_flush() is called, the user expects all of the counters to be
flushed, not just the ones in the current compile unit.

This adds some library functions that register the flush functions. It also
defined __gcov_flush() so that loops through that list and calls the functions.

PR15191 & <rdar://problem/13167507>

llvm-svn: 177337
2013-03-18 22:59:47 +00:00
Dmitry Vyukov 4ddd37ba5b tsan: smaller memory block headers (32b->16b)
llvm-svn: 177312
2013-03-18 19:47:36 +00:00
Dmitry Vyukov 61ce9560d4 tsan: add support for idle threads
llvm-svn: 177292
2013-03-18 17:21:15 +00:00
Dmitry Vyukov ce26a0aa92 tsan: touch less shadow memory during operations on big memory ranges
greatly reduces memory consumption

llvm-svn: 177289
2013-03-18 16:56:48 +00:00
Dmitry Vyukov 2e7f29f042 tsan: mark shadow for thread stack as "don't need" when thread exits
llvm-svn: 177288
2013-03-18 15:49:07 +00:00
Dmitry Vyukov f123337275 tsan: better memory profiler
llvm-svn: 177286
2013-03-18 13:55:33 +00:00
Dmitry Vyukov 15bee188c4 tsan: madvise(DONTNEED) shadow memory on munmap()
llvm-svn: 177278
2013-03-18 11:51:51 +00:00
Kostya Serebryany 9138f75d0a [asan] make the __asan_get_heap_size more robust
llvm-svn: 177270
2013-03-18 10:52:25 +00:00
Dmitry Vyukov 20bf8c7778 tsan: move implementation out of h file
llvm-svn: 177269
2013-03-18 10:32:21 +00:00
Dmitry Vyukov 49e462fab2 tsan: fix clang -Wall build
Clang does not like classes with virtual functions but w/o virtual dtor.
Go does not like libstdc++ (operator delete).

llvm-svn: 177267
2013-03-18 10:10:15 +00:00
Alexey Samsonov b5d10f69e4 [TSan] re-apply r177249 lost in edits
llvm-svn: 177265
2013-03-18 09:45:22 +00:00
Evgeniy Stepanov 6488b2b257 [asan] Switch to allocator2 on Android.
llvm-svn: 177263
2013-03-18 09:22:58 +00:00
Dmitry Vyukov a1bdd2d942 tsan: fix memory leak
llvm-svn: 177262
2013-03-18 09:09:41 +00:00