summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* [PPC64, TSAN] Provide setjmp interceptor support for PPC64Bill Schmidt2015-12-083-2/+388
| | | | | | | | | | | | | | | This patch provides the assembly support for setjmp/longjmp for use with the thread sanitizer. This is a big more complicated than for aarch64, because sibcalls are only legal under our ABIs if the TOC pointer is unchanged. Since the true setjmp function trashes the TOC pointer, and we have to leave the stack in a correct state, we emulate the setjmp function rather than branching to it. We also need to materialize the TOC for cases where the _setjmp code is called from libc. This is done differently under the ELFv1 and ELFv2 ABIs. llvm-svn: 255059
* [PPC64, TSAN] LLVM basic enablement of thread sanitizer for PPC64 (BE and LE)Bill Schmidt2015-12-085-3/+152
| | | | | | | | | | | | | | | | | | This patch is by Simone Atzeni with portions by Adhemerval Zanella. This contains the LLVM patches to enable the thread sanitizer for PPC64, both big- and little-endian. Two different virtual memory sizes are supported: Old kernels use a 44-bit address space, while newer kernels require a 46-bit address space. There are two companion patches that will be added shortly. There is a Clang patch to actually turn on the use of the thread sanitizer for PPC64. There is also a patch that I wrote to provide interceptor support for setjmp/longjmp on PPC64. Patch discussion at reviews.llvm.org/D12841. llvm-svn: 255057
* [TSan] Remove legacy Makefile.old!Alexey Samsonov2015-12-081-63/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: It was barely supported for a several years for now, somewhat rotten and doesn't correspond to the way we build/test TSan runtime in Clang anymore. CMake build has proper compile flags, library layout, build dependencies etc. Shell scripts that depended on the output of Makefile.old are either obsolete now (check_cmake.sh), or moved to lit tests (check_memcpy.sh), or kept as a standalone scripts not suitable for generic test suite, but invoked on bots (check_analyze.sh). It is not used on bots anymore: all "interesting" configurations (gcc/clang as a host compiler; debug/release build types) are now tested via CMake. Reviewers: dvyukov, kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15316 llvm-svn: 255032
* tsan: fix test invisible barrierDmitry Vyukov2015-12-081-0/+36
| | | | | | | | | | | | | | | | | Another attempt at fixing tsan_invisible_barrier. Current implementation causes: https://llvm.org/bugs/show_bug.cgi?id=25643 There were several unsuccessful iterations for this functionality: Initially it was implemented in user code using REAL(pthread_barrier_wait). But pthread_barrier_wait is not supported on MacOS. Futexes are linux-specific for this matter. Then we switched to atomics+usleep(10). But usleep produced parasitic "as-if synchronized via sleep" messages in reports which failed some output tests. Then we switched to atomics+sched_yield. But this produced tons of tsan- visible events, which lead to "failed to restore stack trace" failures. Move implementation into runtime and use internal_sched_yield in the wait loop. This way tsan should see no events from the barrier, so not trace overflows and no "as-if synchronized via sleep" messages. llvm-svn: 255030
* [tsan] Add dispatch_group API interceptors and synchronizationKuba Brecka2015-12-081-1/+64
| | | | | | | | This patch adds release and acquire semantics for dispatch groups, plus a test case. Differential Revision: http://reviews.llvm.org/D15048 llvm-svn: 255020
* [ASan] Retire mac_ignore_invalid_free, remove some dead code.Alexander Potapenko2015-12-041-4/+0
| | | | | | | | | | mac_ignore_invalid_free was helpful when ASan runtime used to intercept CFAllocator and sometimes corrupted its memory. This behavior had been long gone, and the flag was unused. This patch also deletes ReportMacCfReallocUnknown(), which was used by the CFAllocator realloc() wrapper. llvm-svn: 254722
* [tsan] Add interceptors for Darwin-specific locking APIsKuba Brecka2015-12-031-0/+91
| | | | | | | | On OS X, there are other-than-pthread locking APIs that are used quite extensively - OSSpinLock and os_lock_lock. Let's add interceptors for those. Differential Revision: http://reviews.llvm.org/D14987 llvm-svn: 254611
* [tsan] Use re-exec method to enable interceptors on older versions of OS XKuba Brecka2015-12-031-0/+3
| | | | | | | | In AddressSanitizer, we have the MaybeReexec method to detect when we're running without DYLD_INSERT_LIBRARIES (in which case interceptors don't work) and re-execute with the environment variable set. On OS X 10.11+, this is no longer necessary, but to have ThreadSanitizer supported on older versions of OS X, let's use the same method as well. This patch moves the implementation from `asan/` into `sanitizer_common/`. Differential Revision: http://reviews.llvm.org/D15123 llvm-svn: 254600
* [tsan] Add interceptors and sychronization for libdispatch semaphores on OS XKuba Brecka2015-12-011-0/+17
| | | | | | | | This patch adds release and acquire semantics for libdispatch semaphores and a test case. Differential Revision: http://reviews.llvm.org/D14992 llvm-svn: 254412
* [tsan] Fix signals and setjmp/longjmp on OS XKuba Brecka2015-11-302-3/+6
| | | | | | | | | | 1) There's a few wrongly defined things in tsan_interceptors.cc, 2) a typo in tsan_rtl_amd64.S which calls setjmp instead of sigsetjmp in the interceptor, and 3) on OS X, accessing an mprotected page results in a SIGBUS (and not SIGSEGV). Differential Revision: http://reviews.llvm.org/D15052 llvm-svn: 254299
* [tsan] Fix weakly imported functions on OS XKuba Brecka2015-11-307-18/+18
| | | | | | | | | | On OS X, for weak function (that user can override by providing their own implementation in the main binary), we need extern `"C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE`. Fixes a broken test case on OS X, java_symbolization.cc, which uses a weak function __tsan_symbolize_external. Differential Revision: http://reviews.llvm.org/D14907 llvm-svn: 254298
* [tsan] Add release+acquire semantics for serial dispatch queuesKuba Brecka2015-11-281-0/+33
| | | | | | | | Serial queues need extra happens-before between individual tasks executed in the same queue. This patch adds `Acquire(queue)` before the executed task and `Release(queue)` just after it (for serial queues only). Added a test case. Differential Revision: http://reviews.llvm.org/D15011 llvm-svn: 254229
* [tsan] Port tsan_rtl_amd64.S to OS X to add support for setjmp/longjmpKuba Brecka2015-11-282-33/+74
| | | | | | | | | | | | | | This patch ports the assembly file tsan_rtl_amd64.S to OS X, where we need several changes: * Some assembler directives are not available on OS X (.hidden, .type, .size) * Symbol names need to start with an underscore (added a ASM_TSAN_SYMBOL macro for that). * To make the interceptors work, we ween to name the function "_wrap_setjmp" (added ASM_TSAN_SYMBOL_INTERCEPTOR for that). * Calling the original setjmp is done with a simple "jmp _setjmp". * __sigsetjmp doesn't exist on OS X. Differential Revision: http://reviews.llvm.org/D14947 llvm-svn: 254228
* [tsan] Fix an assertion failure in FindThreadByUidLocked with recycled threadsKuba Brecka2015-11-281-8/+8
| | | | | | | | | | | | When a race on file descriptors is detected, `FindThreadByUidLocked()` is called to retrieve ThreadContext with a specific unique_id. However, this ThreadContext might not exist in the thread registry anymore (it may have been recycled), in which case `FindThreadByUidLocked` will cause an assertion failure in `GetThreadLocked`. Adding a test case that reproduces this, producing: FATAL: ThreadSanitizer CHECK failed: sanitizer_common/sanitizer_thread_registry.h:92 "((tid)) < ((n_contexts_))" (0x34, 0x34) This patch fixes this by replacing the loop with `FindThreadContextLocked`. Differential Revision: http://reviews.llvm.org/D14984 llvm-svn: 254223
* [compiler-rt] [tsan] Unify aarch64 mappingAdhemerval Zanella2015-11-267-224/+495
| | | | | | | | | | | | | This patch unify the 39 and 42-bit support for AArch64 by using an external memory read to check the runtime detected VMA and select the better mapping and transformation. Although slower, this leads to same instrumented binary to be independent of the kernel. Along with this change this patch also fix some 42-bit failures with ALSR disable by increasing the upper high app memory threshold and also the 42-bit madvise value for non large page set. llvm-svn: 254151
* [tsan] Fix signal number definitions for OS XKuba Brecka2015-11-241-1/+1
| | | | | | | | On OS X, SIGBUS is 10 and SIGSYS is 12. Differential Revision: http://reviews.llvm.org/D14946 llvm-svn: 253983
* [tsan] Implement basic GCD interceptors for OS XKuba Brecka2015-11-241-0/+66
| | | | | | | | We need to intercept libdispatch APIs (dispatch_sync, dispatch_async, etc.) to add synchronization between the code that submits the task and the code that gets executed (possibly on a different thread). This patch adds release+acquire semantics for dispatch_sync, and dispatch_async (plus their "_f" and barrier variants). The synchronization is done on malloc'd contexts (separate for each submitted block/callback). Added tests to show usage of dispatch_sync and dispatch_async, for cases where we expect no warnings and for cases where TSan finds races. Differential Revision: http://reviews.llvm.org/D14745 llvm-svn: 253982
* [tsan] Fix __cxa_guard_* interceptors on OS XKuba Brecka2015-11-211-3/+20
| | | | | | | | This patch fixes the __cxa_guard_acquire, __cxa_guard_release and __cxa_guard_abort interceptors on OS X. They apparently work on Linux just by having the same name, but on OS X, we actually need to use TSAN_INTERCEPTOR. Differential Revision: http://reviews.llvm.org/D14868 llvm-svn: 253776
* [tsan] For OS X thread finalization, remove g_thread_finalize_key in favor ↵Kuba Brecka2015-11-192-5/+15
| | | | | | | | | | of libpthread hooks On OS X, the thread finalization is fragile due to thread-local variables destruction order. I've seen cases where the we destroy the ThreadState too early and subsequent thread-local values' destructors call interceptors again. Let's replace the TLV-based thread finalization method with libpthread hooks. The notification PTHREAD_INTROSPECTION_THREAD_TERMINATE is called *after* all TLVs have been destroyed. Differential Revision: http://reviews.llvm.org/D14777 llvm-svn: 253560
* [tsan] Recognize frames coming from "libclang_rt.tsan_*" module as internalKuba Brecka2015-11-191-4/+9
| | | | | | | | On OS X, we build a dylib of the TSan runtime, which doesn't necessarily need to contain debugging symbols (and file and line information), so llvm-symbolizer might not be able to find file names for TSan internal frames. FrameIsInternal currently only considers filenames, but we should simply treat all frames within `libclang_rt.tsan_osx_dynamic.dylib` as internal. This patch treats all modules starting with `libclang_rt.tsan_` as internal, because there may be more runtimes for other platforms in the future. Differential Revision: http://reviews.llvm.org/D14813 llvm-svn: 253559
* [tsan] Handle dispatch_once on OS XKuba Brecka2015-11-193-11/+84
| | | | | | | | | | | | | | Reimplement dispatch_once in an interceptor to solve these issues that may produce false positives with TSan on OS X: 1) there is a racy load inside an inlined part of dispatch_once, 2) the fast path in dispatch_once doesn't perform an acquire load, so we don't properly synchronize the initialization and subsequent uses of whatever is initialized, 3) dispatch_once is already used in a lot of already-compiled code, so TSan doesn't see the inlined fast-path. This patch uses a trick to avoid ever taking the fast path (by never storing ~0 into the predicate), which means the interceptor will always be called even from already-compiled code. Within the interceptor, our own atomic reads and writes are not written into shadow cells, so the race in the inlined part is not reported (because the accesses are only loads). Differential Revision: http://reviews.llvm.org/D14811 llvm-svn: 253552
* [tsan] Skip malloc/free interceptors when we're inside symbolizer on OS XKuba Brecka2015-11-181-9/+19
| | | | | | | | Symbolizers can call malloc/realloc/free/..., which we don't want to intercept. This is already implemented on Linux, let's do it for OS X as well. Differential Revision: http://reviews.llvm.org/D14710 llvm-svn: 253460
* [TSan] List only amd64 asm file in Makefile.old (attempt 2)Alexey Samsonov2015-11-181-1/+1
| | | | llvm-svn: 253416
* [TSan] List only amd64 asm file in Makefile.oldAlexey Samsonov2015-11-181-1/+1
| | | | llvm-svn: 253407
* tsan: replace macro check with constant checkDmitry Vyukov2015-11-161-7/+7
| | | | | | As per comments in 252892 commit. llvm-svn: 253216
* [compiler-rt] [tsan] Enable intercept setjmp/longjmp for AArch64Adhemerval Zanella2015-11-162-1/+211
| | | | | | | | | | | | | | | This patch adds assembly routines to enable setjmp/longjmp for aarch64 on linux. It fixes: * test/tsan/longjmp2.cc * test/tsan/longjmp3.cc * test/tsan/longjmp4.cc * test/tsan/signal_longjmp.cc I also checked with perlbench from specpu2006 (it fails to run with missing setjmp/longjmp intrumentation). llvm-svn: 253205
OpenPOWER on IntegriCloud