summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* [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-084-2/+393
| | | | | | | | | | | | | | | 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-082-166/+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
* [CMake] Remove debug output leftovers.Alexey Samsonov2015-12-081-2/+0
| | | | llvm-svn: 255031
* 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
* [TSan] Enforce TSan runtime doesn't include system headers with --sysroot flag.Alexey Samsonov2015-12-071-1/+12
| | | | llvm-svn: 254966
* [TSan] Port check_memcpy.sh script to a regular lit test.Alexey Samsonov2015-12-072-33/+0
| | | | | | | | | | | Check that TSan runtime doesn't contain compiler-inserted calls to memset/memmove functions. In future, we may consider moving this test to test/sanitizer_common, as we don't want to have compiler-inserted memcpy/memmove calls in any sanitizer runtime. llvm-svn: 254955
* [TSan] Slightly improve check_analyze script.Alexey Samsonov2015-12-073-8/+28
| | | | | | | | | De-hardcode path to TSan-ified executable: pass it as an input to the scripts. Fix them so that they don't write to the current directory. Remove their invocation from Makefile.old: they are broken there anyway, as check_analyze.sh now matches trunk Clang. llvm-svn: 254936
* [TSan] Delete legacy test_output.sh script.Alexey Samsonov2015-12-071-3/+0
| | | | | | | | This script is superseded by lit test suite integrated into CMake for quite a while now. It doesn't support many tests, and require custom hacks for a few other. llvm-svn: 254932
* [CMake] Add COMPILER_RT_TSAN_DEBUG_OUTPUT option.Alexey Samsonov2015-12-051-0/+7
| | | | | | | | | This option builds TSan runtime with extra debug printfs and stats collection. This build configuration is developer-only and should rarely be used, but we need to keep it to make sure it doesn't bitrot. llvm-svn: 254818
* [TSan] Fix the wikipage link.Alexander Potapenko2015-12-041-1/+1
| | | | llvm-svn: 254736
* [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] Enable building and testing TSan Go runtime on OS XKuba Brecka2015-12-041-0/+10
| | | | | | | | The build and test actually work now, so let's just enable them. Differential Revision: http://reviews.llvm.org/D15184 llvm-svn: 254716
* [tsan] Add interceptors for Darwin-specific locking APIsKuba Brecka2015-12-032-0/+92
| | | | | | | | 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
* Fixup for r254228 ("Port tsan_rtl_amd64.S to OS X to add support for ↵Kuba Brecka2015-11-291-6/+5
| | | | | | setjmp/longjmp") to fix the build of unit tests. We need to add the ASM file into RTTsan_dynamic as well. llvm-svn: 254249
* [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-283-34/+83
| | | | | | | | | | | | | | 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 CallocOverflow unit test on OS XKuba Brecka2015-11-241-1/+3
| | | | | | | | On OS X, interceptors don't work in unit tests, so calloc() calls the system allocator. We need to use user_calloc() instead. Differential Revision: http://reviews.llvm.org/D14918 llvm-svn: 253979
* [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] Fix detached threads in unit tests on OS XKuba Brecka2015-11-211-2/+5
| | | | | | | | We need to call the intercepted version of pthread_detach. Secondly, PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED are not 0 and 1 on OS X, so we need to properly pass these constants and not just a bool. Differential Revision: http://reviews.llvm.org/D14837 llvm-svn: 253775
* [tsan] Make tsan_test_util_posix.cc call pthread interceptors on OS XKuba Brecka2015-11-211-16/+45
| | | | | | | | The tsan_test_util_posix.cc implementation of mutexes call pthread APIs directly, which on OS X don't end up calling the intercepted versions and we miss the synchronization. This patch changes the unit tests to directly call the intercepted versions. This fixes several test failures on OS X. Differential Revision: http://reviews.llvm.org/D14835 llvm-svn: 253774
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-11-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When ASan currently detects a bug, by default it will only print out the text of the report to stderr. This patch changes this behavior and writes the full text of the report to syslog before we terminate the process. It also calls os_trace (Activity Tracing available on OS X and iOS) with a message saying that the report is available in syslog. This is useful, because this message will be shown in the crash log. For this to work, the patch makes sure we store the full report into error_message_buffer unconditionally, and it also strips out ANSI escape sequences from the report (they are used when producing colored reports). I've initially tried to log to syslog during printing, which is done on Android right now. The advantage is that if we crash during error reporting or the produced error does not go through ScopedInErrorReport, we would still get a (partial) message in the syslog. However, that solution is very problematic on OS X. One issue is that the logging routine uses GCD, which may spawn a new thread on its behalf. In many cases, the reporting logic locks threadRegistry, which leads to deadlocks. Reviewed at http://reviews.llvm.org/D13452 (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid build failures on Linux.) llvm-svn: 253688
* [TSan] Fix custom scripts that validate TSan on non-standard buildbot.Alexey Samsonov2015-11-201-1/+7
| | | | llvm-svn: 253682
* Tell clang-format that (most) sanitizers are written using Google style guide.Alexey Samsonov2015-11-191-0/+1
| | | | llvm-svn: 253608
* [tsan] Replace new/delete with a local variable in ThreadSpecificDtors unit testKuba Brecka2015-11-191-8/+7
| | | | | | | | On OS X, this unit test (ThreadSpecificDtors) fails, because the new and delete operators actually call the overridden operators, which end up using TLVs and crash. Since C++'s new and delete is not important in this test, let's just replace them with a local variable. This fixes the test on OS X. Differential Revision: http://reviews.llvm.org/D14826 llvm-svn: 253583
* [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-194-11/+85
| | | | | | | | | | | | | | 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-163-1/+216
| | | | | | | | | | | | | | | 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
* [tsan] Fix finalization of detached threads on OS XKuba Brecka2015-11-131-1/+1
| | | | | | | | Currently, we crash on finalization of detached threads, because we'll try to clear the ThreadState twice. Differential Revision: http://reviews.llvm.org/D14644 llvm-svn: 253079
* [tsan] Fix a typo in tsan_test_util.hKuba Brecka2015-11-131-1/+1
| | | | | | | | There is a typo in tsan_test_util.h, it shouldn't be `APPLE`, but `__APPLE__`. Differential Revision: http://reviews.llvm.org/D14647 llvm-svn: 253078
* [tsan] Allow symbolizers that don't obtain global symbol sizesKuba Brecka2015-11-121-3/+8
| | | | | | | | The default symbolizer, `llvm-symbolizer` provides sizes for global symbols. On OS X, we want to also allow using `atos` (because it's available everywhere and users don't need to copy/install it) and `dladdr` (it's the only available option when running in a sandbox). However, these symbolizers do not supply the symbol sizes, only names and starting addresses. This patch changes the reporting functions to hide the size of the symbol when this value is unavailable, and modifies tests to make this part of the report "optional". Differential Revision: http://reviews.llvm.org/D14608 llvm-svn: 252896
* tsan: disable abort_on_error for GoDmitry Vyukov2015-11-121-1/+5
| | | | | | | It does not work as expected. Go runtime handles SIGABRT and crashes with a loud message. llvm-svn: 252892
* tsan: fix Go build on linuxDmitry Vyukov2015-11-121-1/+1
| | | | | | librt is not linked in in Go build. llvm-svn: 252877
* tsan: fix unused function warning in Go buildDmitry Vyukov2015-11-121-1/+1
| | | | llvm-svn: 252875
OpenPOWER on IntegriCloud