summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* [PPC64, TSAN] LLVM basic enablement of thread sanitizer for PPC64 (BE and LE)Bill Schmidt2015-12-089-2/+28
| | | | | | | | | | | | | | | | | | 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: fix test invisible barrierDmitry Vyukov2015-12-082-18/+15
| | | | | | | | | | | | | | | | | 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-0/+53
| | | | | | | | 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] Use llvm-objdump+FileCheck instead of standalone .sh script.Alexey Samsonov2015-12-072-27/+5
| | | | llvm-svn: 254959
* [TSan] Port check_memcpy.sh script to a regular lit test.Alexey Samsonov2015-12-072-0/+37
| | | | | | | | | | | 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] Delete legacy test_output.sh script.Alexey Samsonov2015-12-073-74/+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
* [tsan] Enable building and testing TSan Go runtime on OS XKuba Brecka2015-12-041-1/+1
| | | | | | | | 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-031-0/+30
| | | | | | | | 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 MAP_ANON instead of MAP_ANONYMOUSKuba Brecka2015-12-031-1/+1
| | | | | | | | In mmap_large.cc, let's use MAP_ANON instead of MAP_ANONYMOUS, because MAP_ANONYMOUS is only available on OS X 10.11 and later. Differential Revision: http://reviews.llvm.org/D15180 llvm-svn: 254601
* [tsan] Add interceptors and sychronization for libdispatch semaphores on OS XKuba Brecka2015-12-011-0/+29
| | | | | | | | This patch adds release and acquire semantics for libdispatch semaphores and a test case. Differential Revision: http://reviews.llvm.org/D14992 llvm-svn: 254412
* [compiler-rt] Remove SANITIZER_AARCH64_VMA usageAdhemerval Zanella2015-11-3012-46/+29
| | | | | | | | | | | | This patch complete removed SANITIZER_AARCH64_VMA definition and usage. AArch64 ports now supports runtime VMA detection and instrumentation for 39 and 42-bit VMA. It also Rewrite print_address to take a variadic argument list (the addresses to print) and adjust the tests which uses it to the new signature. llvm-svn: 254319
* [tsan] Change comments referencing code.google.com to point to GitHub ↵Kuba Brecka2015-11-3010-10/+10
| | | | | | | | | | instead. NFC. Changing comments that have references to code.google.com to point to GitHub instead, because the current links are not redirected properly (they instead redirect to different issues, mostly ASan). NFC. Differential Revision: http://reviews.llvm.org/D15053 llvm-svn: 254300
* [tsan] Fix signals and setjmp/longjmp on OS XKuba Brecka2015-11-301-1/+7
| | | | | | | | | | 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] Add release+acquire semantics for serial dispatch queuesKuba Brecka2015-11-281-0/+40
| | | | | | | | 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] Add a testcase for a race on a Obj-C instance variableKuba Brecka2015-11-281-0/+55
| | | | | | | | Let's add a testcase for a race on a Obj-C instance variable. Differential Revision: http://reviews.llvm.org/D14988 llvm-svn: 254226
* [tsan] Mark a few more tests with "UNSUPPORTED: darwin"Kuba Brecka2015-11-282-0/+6
| | | | | | | | There's a few more lit tests that require features not available on OS X (MAP_32BIT, pthread_setname_np), let's mark them with "UNSUPPORTED: darwin". Differential Revision: http://reviews.llvm.org/D14923 llvm-svn: 254225
* [tsan] Change mutexset6.cc to use a mutex instead of spinlockKuba Brecka2015-11-281-5/+5
| | | | | | | | Pthread spinlocks are not available on OS X and this test doesn't really require a spinlock. Differential Revision: http://reviews.llvm.org/D14949 llvm-svn: 254224
* [tsan] Fix an assertion failure in FindThreadByUidLocked with recycled threadsKuba Brecka2015-11-281-0/+54
| | | | | | | | | | | | 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-261-1/+1
| | | | | | | | | | | | | 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] Implement basic GCD interceptors for OS XKuba Brecka2015-11-244-0/+140
| | | | | | | | 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 stack_sync_reuse.cc test on OS XKuba Brecka2015-11-241-2/+4
| | | | | | | | The test relies on two variables in different frames to end up being on the same address. For some reason, this isn't true on OS X. This patch adds `__attribute__((aligned(64)))` to the variables, which actually makes the variables occupy the same address. This is still not a guarantee, but it's more likely to work (the test looks very fragile already). Differential Revision: http://reviews.llvm.org/D14925 llvm-svn: 253981
* [tsan] Replace pthread semaphore in signal_cond.cc with barrier_waitKuba Brecka2015-11-241-5/+7
| | | | | | | | | | Pthread semaphores are not available on OS X. Let's replace sem_wait/sem_post with barrier_wait, which makes the test pass on OS X. I know that sem_wait/sem_post is intercepted by TSan, whereas barrier_wait is TSan-invisible, but the purpose of the test is not affected by this. Also, let's properly initialize the mutex and cond variables. Differential Revision: http://reviews.llvm.org/D14924 llvm-svn: 253980
* [tsan] Modify the tls_race.cc and tls_race2.cc tests to pass on OS XKuba Brecka2015-11-232-5/+8
| | | | | | | | On OS X, __thread variables are lazily heap-allocated (with malloc). Therefore, they're recognized as heap blocks (which is what they are) and not as TLS variables in TSan reports. Figuring out if a heap block is a TLS or not is difficult (in malloc interceptor we could analyze the caller and then mark the object), so let's instead modify the tests so that we expect the report to say "Location is heap block" instead of "Location is TLS". Differential Revision: http://reviews.llvm.org/D14873 llvm-svn: 253858
* [TSan] Fix custom scripts that validate TSan on non-standard buildbot.Alexey Samsonov2015-11-201-0/+4
| | | | llvm-svn: 253682
* [tsan] Replace POSIX semaphores with pthread condition variables in ↵Kuba Brecka2015-11-201-6/+14
| | | | | | | | | | vptr_benign_race.cc OS X doesn't support POSIX semaphores (but it does have the API for it, which returns ENOSYS - "Function not implemented"). Differential Revision: http://reviews.llvm.org/D14865 llvm-svn: 253665
* [tsan] Fix deadlock_detector_stress_test.cc testcase for OS XKuba Brecka2015-11-201-1/+5
| | | | | | | | On OS X, we don't have pthread spinlocks, let's just use a regular mutex instead. Secondly, pthread_rwlock_t is much larger (200 bytes), so `char padding_[64 - sizeof(pthread_rwlock_t)]` actually underflows. Differential Revision: http://reviews.llvm.org/D14862 llvm-svn: 253659
* [tsan] Make tests that use CLOCK_MONOTONIC portableKuba Brecka2015-11-204-8/+30
| | | | | | | | Several tests rely on CLOCK_MONOTONIC, which doesn't exist on OS X. This patch fixes these tests by either disabling them (in case of cond_version.c which doesn't make sense on OS X), or by porting the test to also work on OS X. Differential Revision: http://reviews.llvm.org/D14861 llvm-svn: 253658
* [tsan] Implement "%env_tsan_opts" substitution to inherit default TSAN_OPTIONSKuba Brecka2015-11-1922-36/+41
| | | | | | | | We already have %env_asan_opts for ASan, let's implement the same for TSan. Differential Revision: http://reviews.llvm.org/D14698 llvm-svn: 253579
* [tsan] Mark tests that need pthread barriers with "UNSUPPORTED: darwin"Kuba Brecka2015-11-1911-0/+35
| | | | | | | | Several testcases need pthread barriers (e.g. all bench_*.cc which use test/tsan/bench.h) which are not available on OS X. Let's mark them with "UNSUPPORTED: darwin". Differential Revision: http://reviews.llvm.org/D14636 llvm-svn: 253558
* [tsan] Handle dispatch_once on OS XKuba Brecka2015-11-191-0/+55
| | | | | | | | | | | | | | 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
* [compiler-rt] [tsan] Enable intercept setjmp/longjmp for AArch64Adhemerval Zanella2015-11-165-10/+5
| | | | | | | | | | | | | | | 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
* Reverting r253080 ([tsan] Don't demangle names not starting with "_Z").Kuba Brecka2015-11-141-5/+0
| | | | | | This caused bot failures on ARM, e.g. http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9068 llvm-svn: 253129
* [tsan] Don't demangle names not starting with "_Z"Kuba Brecka2015-11-131-0/+5
| | | | | | | | I noticed that when a symbol is named just "x", it gets demangled to "long long". On POSIX, AFAIK, mangled names always start with "_Z", so lets just require that. Differential Revision: http://reviews.llvm.org/D14637 llvm-svn: 253080
* [tsan] Expect memmove interceptor to be called from memcpyKuba Brecka2015-11-133-4/+4
| | | | | | | | On OS X, memcpy and memmove are actually aliases of the same function, so the memmove interceptor can be invoked on a call to memcpy. This patch updates the tests to expect either memmove or memcpy on a stack trace. Differential Revision: http://reviews.llvm.org/D14638 llvm-svn: 253077
* [tsan] Mark dl_iterate_phdr.cc test as unsupported on OS XKuba Brecka2015-11-131-0/+3
| | | | | | | | The dl_iterate_phdr is not present on OS X. Differential Revision: http://reviews.llvm.org/D14643 llvm-svn: 253076
* [tsan] Don't require full paths to be present on stack tracesKuba Brecka2015-11-137-12/+12
| | | | | | | | The OS X symbolizers (namely AtosSymbolizer) don't return full file paths, only file names. This patch modifies `mutexset*.cc` tests not to require a path to be present in the symbol on the stack trace. Differential Revision: http://reviews.llvm.org/D14642 llvm-svn: 253075
* [tsan] Add global symbolication support into AtosSymbolizerKuba Brecka2015-11-131-0/+28
| | | | | | | | This patch adds support for symbolication of globals (implements `SymbolizeData`) for `AtosSymbolizer` on OS X. Differential Revision: http://reviews.llvm.org/D14618 llvm-svn: 253015
* [tsan] Add global symbolication support into DlAddrSymbolizerKuba Brecka2015-11-121-0/+29
| | | | | | | | `DlAddrSymbolizer` is used on OS X when we're running inside a sandbox that prevents us from spawning an external symbolizer. This patch adds support for symbolication of globals (implements `SymbolizeData`) for `DlAddrSymbolizer`. Differential Revision: http://reviews.llvm.org/D14613 llvm-svn: 252899
* [tsan] Allow symbolizers that don't obtain global symbol sizesKuba Brecka2015-11-123-3/+3
| | | | | | | | 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] Add a Darwin-specific lit test directoryKuba Brecka2015-11-123-1/+23
| | | | | | Differential Revision: http://reviews.llvm.org/D14610 llvm-svn: 252887
* tsan: fix flakiness of sleep_sync2 testDmitry Vyukov2015-11-121-1/+4
| | | | llvm-svn: 252869
* [tsan] Skip building libcxx_tsan on OS XKuba Brecka2015-11-091-1/+2
| | | | | | | | The TSan-instrumented version of libcxx doesn't even build on OS X at this point. Let's skip it from the OS X build for now, since most of TSan functionality doesn't depend on it. This will enable `check-tsan` to be run. Differential Revision: http://reviews.llvm.org/D14486 llvm-svn: 252455
* [tsan] Turn lit test deadlocks into failures (OS X)Kuba Brecka2015-11-078-0/+8
| | | | | | | | Several tests currently deadlock when the lit test suite is run on OS X. Let's mark them as unsupported. Differential Revision: http://reviews.llvm.org/D14443 llvm-svn: 252402
* [tsan] Add Darwin support for lit testsKuba Brecka2015-11-061-3/+9
| | | | | | | | | | | This patch enables running lit tests on OS X: 1) Simply enable tests for Darwin (they were restricted to Linux and FreeBSD). 2) Disable using instrumented libcxx (libcxx_tsan) on Darwin. 3) On Darwin, override abort_on_error=0, otherwise all tests would generate crash logs and take much longer to process. Differential Revision: http://reviews.llvm.org/D14439 llvm-svn: 252309
* tsan: make invisible test barrier portableDmitry Vyukov2015-11-062-21/+18
| | | | | | | | | | | The current implementation does not work on darwin and can have issues with other OSes in future. See http://reviews.llvm.org/D14427 Make it portable once and for all (minus usleep call). Reviewed in: http://reviews.llvm.org/D14434 llvm-svn: 252292
* [tsan] Replace pthread_yield with sched_yield in lit testsKuba Brecka2015-11-063-3/+3
| | | | | | | | OS X doesn't have `pthread_yield`. Let's use `sched_yield` instead. Differential Revision: http://reviews.llvm.org/D14428 llvm-svn: 252283
* [tsan] CMake support for TSan on OS XKuba Brecka2015-11-031-1/+1
| | | | | | | | Hi, this patch adds a CMake flag called `COMPILER_RT_ENABLE_TSAN_OSX`, which is off by default. If enabled, the build system will be building the OS X version of the TSan runtime library (called `libclang_rt.tsan_osx_dynamic.dylib`). I'll submit patches that fix OS X build errors shortly. This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point. llvm-svn: 251915
* tsan: add test for issue #602Dmitry Vyukov2015-09-241-0/+28
| | | | llvm-svn: 248522
* [CMake] Remove all uses of LLVM_NATIVE_ARCH.Alexey Samsonov2015-09-081-1/+1
| | | | | | | | | | | | | | | | Instead, assume we're going to target triple specified by COMPILER_RT_DEFAULT_TARGET_TRIPLE and build runtimes for this triple (and hope that the host compiler can target them). This will help users that use cross-compiler on their host to build Clang that would work on a different architecture. This will also come in handy if one would want to configure several compiler-rt build trees on the same host, using just-built Clang that can target many architectures. This doesn't change the behavior in the default build configuration. llvm-svn: 247099
* tsan: speed up race deduplicationDmitry Vyukov2015-09-031-0/+25
| | | | | | | | | | | | | | | | | | | | | | | Race deduplication code proved to be a performance bottleneck in the past if suppressions/annotations are used, or just some races left unaddressed. And we still get user complaints about this: https://groups.google.com/forum/#!topic/thread-sanitizer/hB0WyiTI4e4 ReportRace already has several layers of caching for racy pcs/addresses to make deduplication faster. However, ReportRace still takes a global mutex (ThreadRegistry and ReportMutex) during deduplication and also calls mmap/munmap (which take process-wide semaphore in kernel), this makes deduplication non-scalable. This patch moves race deduplication outside of global mutexes and also removes all mmap/munmap calls. As the result, race_stress.cc with 100 threads and 10000 iterations become 30x faster: before: real 0m21.673s user 0m5.932s sys 0m34.885s after: real 0m0.720s user 0m23.646s sys 0m1.254s http://reviews.llvm.org/D12554 llvm-svn: 246758
OpenPOWER on IntegriCloud