summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl
Commit message (Collapse)AuthorAgeFilesLines
...
* [tsan] Fix synchronization in dispatch_syncKuba Brecka2016-04-071-24/+62
| | | | | | | | In the interceptor for dispatch_sync, we're currently missing synchronization between the callback and the code *after* the call to dispatch_sync. This patch fixes this by adding an extra release+acquire pair to dispatch_sync() and similar APIs. Added a testcase. Differential Revision: http://reviews.llvm.org/D18502 llvm-svn: 265659
* [tsan] Fix freebsd build.Yabin Cui2016-04-051-1/+3
| | | | | | | | | | | | | | Summary: Freebsd doesn't have <sys/personality.h>, so call personality() only in SANITIZER_LINUX. Reviewers: llvm-commits, dvyukov, zatrazz, rengolin, beanz Subscribers: beanz, emaste Differential Revision: http://reviews.llvm.org/D18785 llvm-svn: 265378
* [tsan] Disable randomized address space on aarch64 linux.Yabin Cui2016-04-041-0/+15
| | | | | | | | | | | | | | | | | Summary: After patch https://lkml.org/lkml/2015/12/21/340 is introduced in linux kernel, the random gap between stack and heap is increased from 128M to 36G on 39-bit aarch64. And it is almost impossible to cover this big range. So we need to disable randomized virtual space on aarch64 linux. Reviewers: llvm-commits, zatrazz, dvyukov, rengolin Subscribers: aemerson, rengolin, tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D18526 llvm-svn: 265366
* tsan: fix ignore handling in signal handlersDmitry Vyukov2016-04-041-0/+3
| | | | | | | | | | | We've reset thr->ignore_reads_and_writes, but forget to do thr->fast_state.ClearIgnoreBit(). So ignores were not effective reset and fast_state.ignore_bit was corrupted if signal handler itself uses ignores. Properly reset/restore fast_state.ignore_bit around signal handlers. llvm-svn: 265288
* [tsan] Fix a crash when exiting the main thread (e.g. dispatch_main)Kuba Brecka2016-03-281-1/+5
| | | | | | | | This patch fixes the custom ThreadState destruction on OS X to avoid crashing when dispatch_main calls pthread_exit which quits the main thread. Differential Revision: http://reviews.llvm.org/D18496 llvm-svn: 264627
* [sanitizer] Add memset, memmove, and memcpy to the common interceptorsDerek Bruening2016-03-251-35/+1
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently, sanitizer_common_interceptors.inc has an implicit, undocumented assumption that the sanitizer including it has previously declared interceptors for memset and memmove. Since the memset, memmove, and memcpy routines require interception by many sanitizers, we add them to the set of common interceptions, both to address the undocumented assumption and to speed future tool development. They are intercepted under a new flag intercept_intrin. The tsan interceptors are removed in favor of the new common versions. The asan and msan interceptors for these are more complex (they incur extra interception steps and their function bodies are exposed to the compiler) so they opt out of the common versions and keep their own. Reviewers: vitalybuka Subscribers: zhaoqin, llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D18465 llvm-svn: 264451
* [tsan] Fix fork() and fork-based tests for OS XKuba Brecka2016-03-241-1/+7
| | | | | | | | On OS X, fork() under TSan asserts (in debug builds only) because REAL(fork) calls some intercepted functions, which check that no internal locks are held via CheckNoLocks(). But the wrapper of fork intentionally holds some locks. This patch fixes that by using ScopedIgnoreInterceptors during the call to REAL(fork). After that, all the fork-based tests seem to pass on OS X, so let's just remove all the UNSUPPORTED: darwin annotations we have. Differential Revision: http://reviews.llvm.org/D18409 llvm-svn: 264261
* Revert "[tsan] Disable randomized address space on linux aarch64."Renato Golin2016-03-231-15/+0
| | | | | | | | This reverts commits r264068 and r264079, and they were breaking the build and weren't reverted in time, nor they exhibited expected behaviour from the reviewers. There is more to discuss than just a test fix. llvm-svn: 264150
* [tsan] Fix check-tsan build by using CHECK_NE.Yabin Cui2016-03-221-1/+1
| | | | | | | | | | Reviewers: llvm-commits, srhines, dvyukov Subscribers: srhines Differential Revision: http://reviews.llvm.org/D18361 llvm-svn: 264079
* [tsan] Disable randomized address space on linux aarch64.Yabin Cui2016-03-221-0/+15
| | | | | | | | | | | | | | | | | Summary: After patch https://lkml.org/lkml/2015/12/21/340 is introduced in linux kernel, the random gap between stack and heap is increased from 128M to 36G on 39-bit aarch64. And it is almost impossible to cover this big range. So I think we need to disable randomized virtual space on aarch64 linux. Reviewers: kcc, llvm-commits, eugenis, zatrazz, dvyukov, rengolin Subscribers: rengolin, aemerson, tberghammer, danalbert, srhines, enh Differential Revision: http://reviews.llvm.org/D18003 llvm-svn: 264068
* [sanitizer] Add strchr* to the common interceptorsEvgeniy Stepanov2016-03-211-28/+0
| | | | | | | | | | | | | | | | Adds strchr, strchrnul, and strrchr to the common interceptors, under a new common flag intercept_strchr. Removes the now-duplicate strchr interceptor from asan and all 3 interceptors from tsan. Previously, asan did not intercept strchrnul, but does now; previously, msan did not intercept strchr, strchrnul, or strrchr, but does now. http://reviews.llvm.org/D18329 Patch by Derek Bruening! llvm-svn: 263992
* [tsan] Add some NULL pointer checks into the debugging APIKuba Brecka2016-03-211-5/+5
| | | | | | | | `__tsan_get_report_thread` and others can crash if a stack trace is missing, let's add the missing checks. Differential Revision: http://reviews.llvm.org/D18306 llvm-svn: 263939
* [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
* [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-104-1/+231
| | | | | | | | 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
* tsan: describe heap/data locations in GoDmitry Vyukov2016-03-012-3/+30
| | | | llvm-svn: 262343
* tsan: revert r262037Dmitry Vyukov2016-02-2612-158/+79
| | | | | | Broke aarch64 and darwin bots. llvm-svn: 262046
* tsan: split thread into logical and physical stateDmitry Vyukov2016-02-2612-79/+158
| | | | | | | | | | | | | | | | | | | | 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] 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
* [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
* 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
* [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
* [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
* [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
* [tsan] Define sigaction_t for Android.Yabin Cui2015-12-091-0/+12
| | | | | | | | | | Reviewers: kcc, eugenis, dvyukov Subscribers: llvm-commits, tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D15298 llvm-svn: 255135
* Avoid extended mnemonic 'mfvrsave' in assembly codeBill Schmidt2015-12-091-2/+2
| | | | llvm-svn: 255116
OpenPOWER on IntegriCloud