summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* [sancov] common flags initialization.Mike Aizatsky2016-03-181-1/+1
| | | | | | | | | | | | Summary: Introducing InitializeCommonFlags accross all sanitizers to simplify common flags management. Setting coverage=1 when html_cov_report is requested. Differential Revision: http://reviews.llvm.org/D18273 llvm-svn: 263820
* [tsan] Add interceptor for pthread_cond_timedwait_relative_npKuba Brecka2016-03-181-24/+26
| | | | | | | | On OS X, we have pthread_cond_timedwait_relative_np. TSan needs to intercept this API to avoid false positives when using condition variables. Differential Revision: http://reviews.llvm.org/D18184 llvm-svn: 263782
* [sanitizer] On OS X, verify that interceptors work and abort if not, take 2Kuba Brecka2016-03-172-0/+12
| | | | | | | | | | On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES. TSan unit tests run with a statically linked runtime, where interceptors don't work. To avoid aborting the process in this case, the patch replaces `DisableReexec()` with a weak `ReexecDisabled()` function which is defined to return true in unit tests. Differential Revision: http://reviews.llvm.org/D18212 llvm-svn: 263695
* [tsan] Detect uses of uninitialized, destroyed and invalid mutexesKuba Brecka2016-03-167-0/+19
| | | | | | | | This patch adds a new TSan report type, ReportTypeMutexInvalidAccess, which is triggered when pthread_mutex_lock or pthread_mutex_unlock returns EINVAL (this means the mutex is invalid, uninitialized or already destroyed). Differential Revision: http://reviews.llvm.org/D18132 llvm-svn: 263641
* [sanitizer] Add strlen to the common interceptorsAlexey Samsonov2016-03-111-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds strlen to the common interceptors, under a new common flag intercept_strlen. This provides better sharing of interception code among sanitizers and cleans up the inconsistent type declarations of the previously duplicated interceptors. Removes the now-duplicate strlen interceptor from asan, msan, and tsan. The entry check semantics are normalized now for msan and asan, whose private strlen interceptors contained multiple layers of checks that included impossible-to-reach code. The new semantics are identical to the old: bypass interception if in the middle of init or if both on Mac and not initialized; else, call the init routine and proceed. Patch by Derek Bruening! Reviewers: samsonov, vitalybuka Subscribers: llvm-commits, kcc, zhaoqin Differential Revision: http://reviews.llvm.org/D18020 llvm-svn: 263177
* [tsan] Add TSan debugger APIsKuba Brecka2016-03-105-1/+232
| | | | | | | | Currently, TSan only reports everything in a formatted textual form. The idea behind this patch is to provide a consistent API that can be used to query information contained in a TSan-produced report. User can use these APIs either in a debugger (via a script or directly), or they can use it directly from the process (e.g. in the __tsan_on_report callback). ASan already has a similar API, see http://reviews.llvm.org/D4466. Differential Revision: http://reviews.llvm.org/D16191 llvm-svn: 263126
* sanitizer: Fix endianness checks for gccAlexey Samsonov2016-03-091-2/+2
| | | | | | | | | | | | | | | | | Summary: __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are not supported by gcc, which eg. for ubsan Value::getFloatValue will silently fall through to the little endian branch, breaking display of float values by ubsan. Use __BYTE_ORDER__ == __ORDER_BIG/LITTLE_ENDIAN__ as the condition instead, which is supported by both clang and gcc. Noticed while porting ubsan to s390x. Patch by Marcin Kościelnicki! Differential Revision: http://reviews.llvm.org/D17660 llvm-svn: 263077
* [cmake] Address Samsonov's post-commit review of r262723Filipe Cabecinhas2016-03-052-2/+2
| | | | | | | | | | Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17896 llvm-svn: 262770
* [TSan] Fix compiler warning in Go sanity test.Alexey Samsonov2016-03-042-1/+2
| | | | llvm-svn: 262680
* tsan: describe heap/data locations in GoDmitry Vyukov2016-03-014-31/+105
| | | | llvm-svn: 262343
* tsan: revert r262037Dmitry Vyukov2016-02-2618-226/+99
| | | | | | Broke aarch64 and darwin bots. llvm-svn: 262046
* tsan: split thread into logical and physical stateDmitry Vyukov2016-02-2618-99/+226
| | | | | | | | | | | | | | | | | | | | Currently ThreadState holds both logical state (required for race-detection algorithm, user-visible) and physical state (various caches, most notably malloc cache). Move physical state in a new Process entity. Besides just being the right thing from abstraction point of view, this solves several problems: 1. Cache everything on P level in Go. Currently we cache on a mix of goroutine and OS thread levels. This unnecessary increases memory consumption. 2. Properly handle free operations in Go. Frees are issue by GC which don't have goroutine context. As the result we could not do anything more than just clearing shadow. For example, we leaked sync objects and heap block descriptors. 3. This will allow to get rid of libc malloc in Go (now we have Processor context for internal allocator cache). This in turn will allow to get rid of dependency on libc entirely. 4. Potentially we can make Processor per-CPU in C++ mode instead of per-thread, which will reduce resource consumption. The distinction between Thread and Processor is currently used only by Go, C++ creates Processor per OS thread, which is equivalent to the current scheme. llvm-svn: 262037
* [sanitizer] Move recvmsg and recv interceptors to sanitizer_common.Maxim Ostapenko2016-02-251-12/+0
| | | | | | | | | This patch moves recv and recvfrom interceptors from MSan and TSan to sanitizer_common to enable them in ASan. Differential Revision: http://reviews.llvm.org/D17479 llvm-svn: 261841
* tsan: clean up code after r261658Dmitry Vyukov2016-02-231-2/+0
| | | | llvm-svn: 261660
* tsan: fix signal handling in ignored librariesDmitry Vyukov2016-02-231-6/+26
| | | | | | | | | | | | | | The first issue is that we longjmp from ScopedInterceptor scope when called from an ignored lib. This leaves thr->in_ignored_lib set. This, in turn, disables handling of sigaction. This, in turn, corrupts tsan state since signals delivered asynchronously. Another issue is that we can ignore synchronization in asignal handler, if the signal is delivered into an IgnoreSync region. Since signals are generally asynchronous, they should ignore memory access/synchronization/interceptor ignores. This could lead to false positives in signal handlers. llvm-svn: 261658
* Change comma to semi-colon, no functionality change.Richard Trieu2016-02-181-1/+1
| | | | | | Cleanup for upcoming Clang warning -Wcomma. llvm-svn: 261269
* [tsan] Disable sysroot flag on FreeBSDEd Maste2016-02-181-1/+5
| | | | | | | | | | | | FreeBSD does not install a number of Clang-provided headers for the compiler in the base system due to incompatibilities between FreeBSD's and Clang's versions. As a workaround do not use --sysroot=. on FreeBSD until this is addressed. llvm.org/pr26651 Differential Revision: http://reviews.llvm.org/D17383 llvm-svn: 261229
* [tsan] Fix signal number definitions for FreeBSDEd Maste2016-02-171-1/+1
| | | | | | The change in r253983 for OS X also applies to FreeBSD. llvm-svn: 261121
* [tsan] Fix build warnings on FreeBSDEd Maste2016-02-171-2/+2
| | | | | | The change in r252165 for OS X applies to FreeBSD as well. llvm-svn: 261120
* Fix lib/tsan/go/buildgo.sh for FreeBSD after r243051.Dimitry Andric2016-02-141-13/+14
| | | | | | | | | | FreeBSD also needs to have sanitizer_linux_libcdep.cc included, otherwise linking will fail with "undefined reference to `__sanitizer::GetRSS()'". While here, tabify the FreeBSD part, similar to the other parts. llvm-svn: 260839
* [TSan] Adjust expectation for check_analyze.shAlexey Samsonov2016-02-131-1/+7
| | | | | | | | | | r260695 caused extra push/pop instruction pair in __tsan_read1 implementation. Still, that change in InstCombine is believed to be good, as it reduces the number of instructions performed. Adjust the expectations to match the newly generated code. llvm-svn: 260775
* [TSan] Fix PrintMatchedSuppressions: Read hit count for suppression atomicallyMohit K. Bhakkad2016-02-041-2/+2
| | | | | | | | Reviewers: dvyukov. Subscribers: jaydeep, sagar, dsanders, llvm-commits. Differential Revision: http://reviews.llvm.org/D16845 llvm-svn: 259755
* Re-commit r259512: [tsan] Add a libc++ and lit testsuite for each ↵Daniel Sanders2016-02-021-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ${TSAN_SUPPORTED_ARCH}. Summary: This is a workaround to a problem in the 3.8 release that affects MIPS and possibly other targets where the default is not supported but a sibling is supported. When TSAN_SUPPORTED_ARCH is not empty, cmake currently attempts to build a tsan'd libcxx as well as test tsan for the default target regardless of whether the default target is supported or not. This causes problems on MIPS32 since tsan is supported for MIPS64 but not MIPS32. This patch causes cmake to only build the libcxx and run the lit test-suite for archictures in ${TSAN_SUPPORTED_ARCH} This re-commit fixes an issue where 'check-tsan' continued to look for the tsan'd libc++ in the directory it used to be built in. Reviewers: hans, samsonov Subscribers: tberghammer, llvm-commits, danalbert, srhines, dvyukov Differential Revision: http://reviews.llvm.org/D16685 llvm-svn: 259542
* Revert r259512 - [tsan] Add a libc++ and lit testsuite for each ↵Daniel Sanders2016-02-021-11/+4
| | | | | | | | | ${TSAN_SUPPORTED_ARCH}. check-tsan does not pick up the correct libc++.so. It succeeded on my machine by picking up the libc++.so that was built before making this change. llvm-svn: 259519
* [tsan] Add a libc++ and lit testsuite for each ${TSAN_SUPPORTED_ARCH}.Daniel Sanders2016-02-021-4/+11
| | | | | | | | | | | | | | | | | | | | | | | Summary: This is a workaround to a problem in the 3.8 release that affects MIPS and possibly other targets where the default is not supported but a sibling is supported. When TSAN_SUPPORTED_ARCH is not empty, cmake currently attempts to build a tsan'd libcxx as well as test tsan for the default target regardless of whether the default target is supported or not. This causes problems on MIPS32 since tsan is supported for MIPS64 but not MIPS32. This patch causes cmake to only build the libcxx and run the lit test-suite for archictures in ${TSAN_SUPPORTED_ARCH} Reviewers: hans, samsonov Subscribers: tberghammer, llvm-commits, danalbert, srhines, dvyukov Differential Revision: http://reviews.llvm.org/D16685 llvm-svn: 259512
* Fix another -Wexpansion-to-defined warning in compiler-rt.Nico Weber2016-01-191-1/+5
| | | | llvm-svn: 258202
* tsan: add back __tls_get_addr interceptorDmitry Vyukov2016-01-191-0/+15
| | | | | | | | Removal of the interceptor broke libtsan interface in gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68824 Add back a simple interceptor. llvm-svn: 258119
* [tsan] Do nothing in ScopedInterceptor's destructor if thr is not inited.Yabin Cui2016-01-171-0/+2
| | | | | | | | | | | | Summary: It is part of http://reviews.llvm.org/D15301, but missed when I committed that patch. Reviewers: kubabrecka, kcc, eugenis, llvm-commits, dvyukov Differential Revision: http://reviews.llvm.org/D16235 llvm-svn: 258021
* [tsan] Fix some tiny errors.Yabin Cui2016-01-152-5/+7
| | | | | | | | | | | | | | Summary: 1. Fix spell error for sigaction. 2. Make line_length <= 80. Reviewers: llvm-commits, eugenis, kcc, dvyukov Subscribers: tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D16210 llvm-svn: 257872
* [tsan] Store the pointer to ThreadState in TLS slot on Android.Yabin Cui2016-01-154-6/+70
| | | | | | | | | | | | | | | | | | | | Summary: 1. Android doesn't support __thread keyword. So allocate ThreadState dynamically and store its pointer in one TLS slot provided by Android. 2. On Android, intercepted functions can be called before ThreadState is initialized. So add test of thr_->is_inited in some places. 3. On Android, intercepted functions can be called after ThreadState is destroyed. So add a fake dead_thread_state to represent all destroyed ThreadStates. And that is also why we don't store the pointer to ThreadState in shadow memory of pthread_self(). Reviewers: kcc, eugenis, dvyukov Subscribers: kubabrecka, llvm-commits, tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D15301 llvm-svn: 257866
* [tsan] Use internal_sigfillset to replace REAL(sigfillset).Yabin Cui2016-01-151-4/+2
| | | | | | | | | | | | | | Summary: Android doesn't intercept sigfillset, so REAL(sigfillset) is null. And we can use internal_sigfillset() for all cases. Reviewers: kcc, eugenis, kubabrecka, dvyukov Subscribers: llvm-commits, tberghammer, danalbert Differential Revision: http://reviews.llvm.org/D15296 llvm-svn: 257862
* Fix the cross compilation of unit tests. NFC (second attempt)Sumanth Gundapaneni2016-01-141-1/+1
| | | | | | | | | | | | | | | | With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compiling environment, the unit tests fail to link. This patch does the following changes >Rename COMPILER_RT_TEST_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS to reflect the way it's used. >Add COMPILER_RT_TEST_COMPILER_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that cross-compiler would be able to build/compile the unit tests >Add COMPILER_RT_UNITTEST_LINKFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that cross-compiler would be able to link the unit tests (if needed) Differential Revision: http://reviews.llvm.org/D16165 llvm-svn: 257783
* [tsan] Introduce a "ignore_interceptors_accesses" optionKuba Brecka2016-01-142-0/+12
| | | | | | | | On OS X, TSan already passes all unit and lit tests, but for real-world applications (even very simple ones), we currently produce a lot of false positive reports about data races. This makes TSan useless at this point, because the noise dominates real bugs. This introduces a runtime flag, "ignore_interceptors_accesses", off by default, which makes TSan ignore all memory accesses that happen from interceptors. This will significantly lower the coverage and miss a lot of bugs, but it eliminates most of the current false positives on OS X. Differential Revision: http://reviews.llvm.org/D15189 llvm-svn: 257760
* [tsan] Fix the value of PTHREAD_MUTEX_RECURSIVE for OS X and FreeBSDKuba Brecka2016-01-141-0/+5
| | | | | | | | The value of the constant PTHREAD_MUTEX_RECURSIVE is not "1" on FreeBSD and OS X. Differential Revision: http://reviews.llvm.org/D16075 llvm-svn: 257758
* Revert r257686 "With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross ↵Hans Wennborg2016-01-131-1/+1
| | | | | | | | | | | | | | | compiling" This broke the build. For example, from http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/1191/steps/cmake%20stage%201/logs/stdio: -- Compiler-RT supported architectures: aarch64 CMake Error at projects/compiler-rt/cmake/Modules/AddCompilerRT.cmake:170 (string): string sub-command REPLACE requires at least four arguments. Call Stack (most recent call first): projects/compiler-rt/lib/CMakeLists.txt:4 (include) llvm-svn: 257694
* With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compilingSumanth Gundapaneni2016-01-131-1/+1
| | | | | | | | | | | | | | | environment, the unit tests fail to link. This patch does the following changes >Rename COMPILER_RT_TEST_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS to reflect the way it's used. >Add COMPILER_RT_TEST_COMPILER_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that cross-compiler would be able to build/compile the unit tests >Add COMPILER_RT_UNITTEST_LINKFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that cross-compiler would be able to link the unit tests (if needed) Differential Revision:http://reviews.llvm.org/D15082 llvm-svn: 257686
* [tsan] don't crash on closedir(0)Kostya Serebryany2016-01-081-2/+4
| | | | llvm-svn: 257223
* [compiler-rt] [tsan] Add support for PIE build on AArch64Adhemerval Zanella2015-12-212-6/+56
| | | | | | | | | | | | | | | | | | | This patch adds PIE executable support for aarch64-linux. It adds two more segments: - 0x05500000000-0x05600000000: 39-bits PIE program segments - 0x2aa00000000-0x2ab00000000: 42-bits PIE program segments Fortunately it is possible to use the same transformation formula for the new segments range with some adjustments in shadow to memory formula (it adds a constant offset based on the VMA size). A simple testcase is also added, however it is disabled on x86 due the fact it might fail on newer kernels [1]. [1] https://git.kernel.org/linus/d1fd836dcf00d2028c700c7e44d2c23404062c90 llvm-svn: 256184
* Revert r255996 ("[tsan] Add a DCHECK to verify __tsan_read* and __tsan_write ↵Kuba Brecka2015-12-183-46/+62
| | | | | | | | function aren't called from ScopedInterceptor"). There are some test failures on the Linux buildbots. llvm-svn: 255997
* [tsan] Add a DCHECK to verify __tsan_read* and __tsan_write function aren't ↵Kuba Brecka2015-12-183-62/+46
| | | | | | | | | | called from ScopedInterceptor Interceptors using ScopedInteceptor should never call into user's code before the ScopedInterceptor is out of scope (and its destructor is called). Let's add a DCHECK to enforce that. Differential Revision: http://reviews.llvm.org/D15381 llvm-svn: 255996
* [tsan] Fix scoping of ScopedInteceptor in libdispatch supportKuba Brecka2015-12-183-0/+36
| | | | | | | | Some interceptors in tsan_libdispatch_mac.cc currently wrongly use TSAN_SCOPED_INTERCEPTOR/ScopedInterceptor. Its constructor can start ignoring memory accesses, and the destructor the stops this -- however, e.g. dispatch_sync can call user's code, so the ignoring will extend to user's code as well. This is not expected and we should only limit the scope of ScopedInterceptor to TSan code. This patch introduces annotations that mark the beginning and ending of a callback into user's code. Differential Revision: http://reviews.llvm.org/D15419 llvm-svn: 255995
* [TSAN, PPC64] Fix obvious typo of supported virtual memory sizesBill Schmidt2015-12-141-1/+1
| | | | llvm-svn: 255507
* [tsan] Update dispatch_group support to avoid using a disposed group objectKuba Brecka2015-12-141-0/+19
| | | | | | | | | | We're using the dispatch group itself to synchronize (to call Release() and Acquire() on it), but in dispatch group notifications, the group can already be disposed/deallocated. This causes a later assertion failure at `DCHECK_EQ(*meta, 0);` in `MetaMap::AllocBlock` when the same memory is reused (note that the failure only happens in debug builds). Fixing this by retaining the group and releasing it in the notification. Adding a stress test case that reproduces this. Differential Revision: http://reviews.llvm.org/D15380 llvm-svn: 255494
* [TSan] Try harder to avoid compiler-generated memcpy calls.Alexey Samsonov2015-12-102-2/+2
| | | | | | | | check_memcpy test added in r254959 fails on some configurations due to memcpy() calls inserted by Clang. Try harder to avoid them by using internal_memcpy() where applicable. llvm-svn: 255287
* Revert "[CMake] Provide options for toggling on and off various runtime ↵Chris Bieneman2015-12-101-2/+0
| | | | | | | | libraries." This reverts r255170. This change caused a bunch of bot failures and needs to be revised. llvm-svn: 255184
* [CMake] Provide options for toggling on and off various runtime libraries.Chris Bieneman2015-12-091-0/+2
| | | | | | | | | | | | | | | Summary: Rather than having to add new "experimental" options each time someone wants to work on bringing a sanitizer to a new platform, this patch makes options for all of them. The default values for the options are set by the platform checks that would have enabled them, but they can be overridden on or off. Reviewers: kubabrecka, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14846 llvm-svn: 255170
* [tsan] Move emptyset/oldset to ThreadSignalContext.Yabin Cui2015-12-091-5/+6
| | | | | | | | | | | | | | Summary: Android doesn't support __thread keyword. So move emptyset/oldset from THREADLOCAL to ThreadSignalContext. Reviewers: kcc, eugenis, dvyukov Subscribers: llvm-commits, tberghammer, danalbert Differential Revision: http://reviews.llvm.org/D15299 llvm-svn: 255168
* [tsan] Use REAL(malloc) instead of __libc_malloc for Android.Yabin Cui2015-12-092-2/+11
| | | | | | | | | | | | | | | Summary: Android doesn't have __libc_malloc and related allocation functions. As its dynamic linker doesn't use malloc, so we can use REAL(malloc) to replace __libc_malloc safely. Reviewers: kcc, eugenis, dvyukov Subscribers: llvm-commits, tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D15297 llvm-svn: 255167
* [tsan] Disable interceptors not supported in Android.Yabin Cui2015-12-092-17/+21
| | | | | | | | | | Reviewers: kcc, eugenis, dvyukov Subscribers: llvm-commits, tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D15295 llvm-svn: 255164
* [TSan] Try harder to avoid compiler-generated memset calls.Alexey Samsonov2015-12-093-5/+6
| | | | | | | | | | check_memcpy test added in r254959 fails on some configurations due to memset() calls inserted by Clang. Try harder to avoid them: * Explicitly use internal_memset() instead of empty braced-initializer. * Replace "new T()" with "new T", as the former generates zero-initialization for structs in C++11. llvm-svn: 255136
OpenPOWER on IntegriCloud