Commit Graph

4030 Commits

Author SHA1 Message Date
Dmitry Vyukov 26411d6929 tsan: more precise handling of atexit callbacks
Fixes issue https://code.google.com/p/thread-sanitizer/issues/detail?id=74

llvm-svn: 216906
2014-09-02 14:22:31 +00:00
Dmitry Vyukov 8bbb17dcc3 tsan: disable getpwent interceptors
There interceptors do not seem to be strictly necessary for tsan.
But we see cases where the interceptors consume 70% of execution time.
Memory blocks passed to fgetgrent_r are "written to" by tsan several times.
First, there is some recursion (getgrnam_r calls fgetgrent_r), and each
function "writes to" the buffer. Then, the same memory is "written to"
twice, first as buf and then as pwbufp (both of them refer to the same addresses).

llvm-svn: 216904
2014-09-02 12:51:11 +00:00
Dmitry Vyukov 1841219abd tsan: restructure signal handling to allow recursive handling
Fixes issue
https://code.google.com/p/thread-sanitizer/issues/detail?id=71

llvm-svn: 216903
2014-09-02 12:27:45 +00:00
Dmitry Vyukov dc1caa7cb8 tsan: address comments in r214912
See http://reviews.llvm.org/D4794

llvm-svn: 216900
2014-09-02 09:34:34 +00:00
Alexander Potapenko 3ae9193371 [libsanitizer] Fix the Android build.
llvm-svn: 216885
2014-09-01 15:38:16 +00:00
Evgeniy Stepanov 21202ba8dd [asan] Update asan_device_setup to support Android L Preview.
llvm-svn: 216884
2014-09-01 15:37:50 +00:00
Alexander Potapenko a909e493f1 [libsanitizer] Make sanitizer_unwind_posix.cc a libcdep source file.
Guard the source with #if SANITIZER_POSIX to fix compilation on Windows.
use it only in 

llvm-svn: 216882
2014-09-01 13:07:50 +00:00
Dmitry Vyukov 34fb3799a3 tsan: fix false positive related to signal handlers
Users expect synchronization between sigaction and arrival
of the signal. See the test for details.

llvm-svn: 216878
2014-09-01 12:46:42 +00:00
Alexander Potapenko 4d84996186 [ASan] Small refactoring - split the slow unwinding logic into sanitizer_unwind_posix.cc
This allows the slow unwinder to be used on OSX (it's disabled for now, see
https://code.google.com/p/address-sanitizer/issues/detail?id=137 for details)

llvm-svn: 216877
2014-09-01 12:43:03 +00:00
Dmitry Vyukov aa8fa60ba8 tsan: unbreak windows build
Currently it fails with:

# Testing race detector.
race_windows_amd64.syso:gotsan.cc:(.text+0x4d89): undefined reference to `__imp_SymGetModuleBase64'
race_windows_amd64.syso:gotsan.cc:(.text+0x4d90): undefined reference to `__imp_SymFunctionTableAccess64'
race_windows_amd64.syso:gotsan.cc:(.text+0x4dd8): undefined reference to `__imp_StackWalk64'
x86_64-w64-mingw32/bin/ld.exe: race_windows_amd64.syso
: bad reloc address 0x10 in section `.data'
collect2.exe: error: ld returned 1 exit status

llvm-svn: 216875
2014-09-01 11:44:59 +00:00
Kostya Serebryany c148f7c3af [asan] enable poison_array_cookie back
llvm-svn: 216705
2014-08-29 01:16:18 +00:00
Kostya Serebryany ac77055272 [asan] introduce __asan_load_cxx_array_cookie: check that the array cookie address is properly poisoned and return the cookie value. If not, return 0 to avoid infinite loop of DTORs (in case of use-after-free). Calls to this function will be inserted by clang (separate change)
llvm-svn: 216692
2014-08-28 22:28:04 +00:00
Kostya Serebryany 1e3b338606 [asan] disable poison_array_cookie while I am investigating a false positive on chromium (I suspect that LLVM looses nosanitizer metadata; no test yet)
llvm-svn: 216684
2014-08-28 20:24:05 +00:00
Timur Iskhodzhanov 737370da20 [ASan/Win] Add the -Zl flag to avoid /DEFAULTLIB:libcmt directive in the asan_win_uar_thunk object file
This directive results in 'symbol already defined' when linking DLLs that use -MD

llvm-svn: 216663
2014-08-28 12:28:04 +00:00
Alexander Potapenko 83061238d4 [ASan] Whitespace fix. No functionality change.
llvm-svn: 216544
2014-08-27 13:43:18 +00:00
Evgeniy Stepanov 8f4e736080 [asan] Restore asan-rt name on linux back to pre-r216380.
There is no reason to have different library names for shared and static
cases on linux. It also breaks Android where we install the shared asan-rt
library into the system and should keep the old name.

This change reverts most of r216380 limiting it to win32 targets only.

llvm-svn: 216533
2014-08-27 09:46:54 +00:00
Sergey Matveev 08347ca4fd [lsan] Implement the public allocator interface in standalone LSan.
llvm-svn: 216459
2014-08-26 14:28:28 +00:00
Sergey Matveev 93a2906e80 [lsan] Implement __sanitizer_print_stack_trace() in standalone LSan.
llvm-svn: 216454
2014-08-26 12:52:41 +00:00
Timur Iskhodzhanov 81885731a8 [ASan/Win] Rename asan_dll_thunk.cc to asan_win_dll_thunk.cc
llvm-svn: 216448
2014-08-26 10:21:37 +00:00
Timur Iskhodzhanov 6903e10ddf [ASan/Win] Add an extra thunk.lib to handle stack-use-after-return option
With this patch, "check-asan" passes all the tests with both MT and MD ASan RTL if you set COMPILER_RT_BUILD_SHARED_ASAN to ON
(PR20214)

llvm-svn: 216447
2014-08-26 10:08:24 +00:00
Kostya Serebryany 74bd6bc9f9 [sanitizer] move mlock interceptor from asan/tsan/msan to common; no functionality change intended
llvm-svn: 216407
2014-08-25 20:57:59 +00:00
Timur Iskhodzhanov dc8caada51 [ASan/Win] Add /DEBUG to the MD RTL link flags
llvm-svn: 216387
2014-08-25 16:45:53 +00:00
Timur Iskhodzhanov 2311f4dfaa [ASan] Replace CMake if/APPEND/endif with append_if
llvm-svn: 216386
2014-08-25 16:40:39 +00:00
Timur Iskhodzhanov 0a88b25c43 [ASan/Win] Intercept memory allocation functions in the MD CRT
llvm-svn: 216382
2014-08-25 13:19:05 +00:00
Timur Iskhodzhanov ea3ce790dc [ASan] Rename the ASan dynamic RT
Reviewed at http://reviews.llvm.org/D5026

llvm-svn: 216380
2014-08-25 11:44:06 +00:00
Alexey Samsonov 2ccbc621df [UBSan] Add support for printing backtraces to all UBSan handlers
llvm-svn: 216289
2014-08-22 21:42:04 +00:00
Timur Iskhodzhanov 220ddacf8d [ASan/Win] Land the trivial bits of -MD RTL support (PR20214)
llvm-svn: 216265
2014-08-22 12:38:07 +00:00
Timur Iskhodzhanov f2d24473fe [ASan] Use check_library_exists to determine if libc/libstdc++ are available
llvm-svn: 216264
2014-08-22 12:26:34 +00:00
Alexander Potapenko 373863d31e Follow-up for r215436: use SIZE_T for strlen and wcslen interceptors.
llvm-svn: 216184
2014-08-21 16:12:46 +00:00
Timur Iskhodzhanov a14ef30443 [ASan] Turns out we should always intercept __cxa_throw
At least check-asan works with this change.

If the change breaks anything, we'll need to add:
a) a comment describing why we have to use INTERCEPT_FUNCTION rather than
   ASAN_INTERCEPT_FUNC
and
b) a test case.

llvm-svn: 216177
2014-08-21 13:33:39 +00:00
Peter Collingbourne 82ff058cf9 DFSan's set label function should avoid writing to the shadow memory when the write would not change the value in memory.
When writing a label to shadow memory, don't write if the value is already set to the value being written.  This dramatically reduces real memory consumption in programs with sparse use of labels.

Test Plan: It would be nice to test that unnecessary writes are skipped, but I do not see how a unit test could do this.

Patch by Sam Kerner!

Differential Revision: http://reviews.llvm.org/D4894

llvm-svn: 215961
2014-08-19 01:47:33 +00:00
Alexey Samsonov 2e39027931 [LSan] Parse common flags from LSAN_OPTIONS even if LSan is combined with
another sanitizer.

A user may run both LSan and LSan+ASan. It is weird to pass path to leak
suppression file (or other common sanitizer flags, like "verbosity") in
"LSAN_OPTIONS" in the first case and in "ASAN_OPTIONS" in the second case.

llvm-svn: 215949
2014-08-18 23:39:47 +00:00
Justin Bogner 8da47ac82e profile: Improve error messages on bad GCDA files
llvm-svn: 215933
2014-08-18 20:47:32 +00:00
Hans Wennborg 4834653872 sanitizer_printf.cc: guard the va_copy hack on _MSC_VER
llvm-svn: 215932
2014-08-18 20:23:16 +00:00
Hans Wennborg a2d4b09a55 Revert "[ASan/Win] Remove a hack that seems not to be required with VS2013 anymore" (r215708)
This is still needed for VS2012.

llvm-svn: 215930
2014-08-18 19:55:35 +00:00
Alexey Samsonov cd21e2f7e4 [TSan] Initialize flags as early as possible. Disables back coredump, accidentally enabled in r215479. Add a test.
llvm-svn: 215763
2014-08-15 19:53:51 +00:00
Timur Iskhodzhanov 48e21c07c1 Follow-up to r215724: fix a lint warning
llvm-svn: 215725
2014-08-15 16:10:02 +00:00
Timur Iskhodzhanov 5c84264194 [ASan/Win] Introduce a new macro for malloc-like function attributes; also, clang-format the definitions of these functions
llvm-svn: 215724
2014-08-15 16:08:53 +00:00
Timur Iskhodzhanov 3e00116dc1 [ASan/Win] Remove one more reference to __interception::GetRealFunctionAddress (follow-up to r215707)
llvm-svn: 215722
2014-08-15 15:41:03 +00:00
Timur Iskhodzhanov f8b1cd210d [ASan/Win] We don't really need to use .CRT to call __asan_init when using -MD
llvm-svn: 215719
2014-08-15 14:44:17 +00:00
Timur Iskhodzhanov cc01fad1d9 [ASan/Win] Remove a hack that seems not to be required with VS2013 anymore
llvm-svn: 215708
2014-08-15 13:45:23 +00:00
Timur Iskhodzhanov 750f1cf9e4 [ASan/Win] Remove old, unused and non-functional code that will be re-written soon
llvm-svn: 215707
2014-08-15 12:56:52 +00:00
Dmitry Vyukov 5f86aaa27b tsan: fix unaligned memory access routine
It was possimitically handling an aligned 8-byte access as 2 4-byte accesses.

llvm-svn: 215546
2014-08-13 13:20:23 +00:00
Alexey Samsonov de443c5002 [UBSan] Add returns-nonnull sanitizer.
Summary:
This patch adds a runtime check verifying that functions
annotated with "returns_nonnull" attribute do in fact return nonnull pointers.
It is based on suggestion by Jakub Jelinek:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140623/223693.html.

Test Plan: regression test suite

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4849

llvm-svn: 215485
2014-08-13 00:26:40 +00:00
Alexey Samsonov 5a32f79af3 [MSan] Disable coredump for 64-bit binaries.
llvm-svn: 215482
2014-08-12 22:37:47 +00:00
Alexey Samsonov 34e2b280da [TSan] Share the code the setup code calling getrlim/setrlim with sanitizer_common
llvm-svn: 215481
2014-08-12 22:31:19 +00:00
Alexey Samsonov d2d2457823 [Sanitizer] Make disable_coredump a common flag and use it in TSan
llvm-svn: 215479
2014-08-12 22:07:48 +00:00
Alexey Samsonov b9ec65cd4d [Sanitizer] Kill deprecated allocator interfaces in ASan, MSan and TSan in favor of
a unified interface in <sanitizer/allocator_interface.h>.

llvm-svn: 215469
2014-08-12 20:28:20 +00:00
Timur Iskhodzhanov 6963686c47 [ASan] Use more appropriate return types for strlen/wcslen to avoid MSVC warnings
llvm-svn: 215436
2014-08-12 11:02:53 +00:00
Alexey Samsonov 968a358974 [ASan] Add new options for asan_symbolize.py script.
The patch adds new features in asan-symbolizer script which are helpful for using ASan on embedded systems:

1) add cross-compile prefix for binutils
2) define path to sysroot with sanitized binaries

Features are enabled by command line options.
The patch also extends command line interface with help option.

Reviewed in http://reviews.llvm.org/D4703.

Patch by Maria Guseva!

llvm-svn: 215381
2014-08-11 20:02:49 +00:00