summaryrefslogtreecommitdiff
path: root/test/tsan
AgeCommit message (Collapse)Author
2017-06-07Revert "Fix tsan test for Darwin. NFCI."Vedant Kumar
This reverts commit r304941. Vitaly Buka writes: "Actually it depends on return value. Test is for char* version of function. It will probably fail for int version." git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304943 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07Fix tsan test for Darwin. NFCI.Vedant Kumar
On Darwin, strerror_r returns an int, not a char*. I don't think this test really depends on what strerror_r returns, so I've used something else in place of the result of the call to strerror_r. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304941 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07[tsan]: Fix GNU version of strerror_r interceptorVitaly Buka
GNU version of strerror_r returns a result pointer that doesn't match the input buffer. The result pointer is in fact a pointer to some internal storage. TSAN was recording a write to this location, which was incorrect. Fixed https://github.com/google/sanitizers/issues/696 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304858 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03[tsan] Detect races on modifying accesses in Swift codeKuba Mracek
This patch allows the Swift compiler to emit calls to `__tsan_external_write` before starting any modifying access, which will cause TSan to detect races on arrays, dictionaries and other classes defined in non-instrumented modules. Races on collections from the Swift standard library and user-defined structs and a frequent cause of subtle bugs and it's important that TSan detects those on top of existing LLVM IR instrumentation, which already detects races in direct memory accesses. Differential Revision: https://reviews.llvm.org/D31630 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302050 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01[powerpc] deactivate flakey tests on powerpc64leBill Seurer
These test cases occassionally fail when run on powerpc64le: ignore_lib1.cc ignore_lib5.cc TestCases/Posix/current_allocated_bytes.cc rtl/TsanRtlTest/Posix.ThreadLocalAccesses TestCases/Posix/coverage-fork-direct.cc The failures cause false problem reports to be sent to developers whose code had nothing to do with the failures. Reactivate them when the real problems are fixed. This could also be related to the same problems as with the tests ThreadedOneSizeMallocStressTest, ThreadedMallocStressTest, ManyThreadsTest, and several others that do not run reliably on powerpc. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301798 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27TSan: update line number after XFAIL on iOS.Tim Northover
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301560 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26XFAIL the TSan XPC tests on iOS. XPC isn't available on iOS.Kuba Mracek
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301459 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24[tsan] Include __tsan_external_* API from a header file instead of declaring ↵Kuba Mracek
them manually. NFC. Differential Revision: https://reviews.llvm.org/D32384 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301190 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24[tsan] Remove the extra word "object" from description of external racesKuba Mracek
Differential Revision: https://reviews.llvm.org/D32383 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301189 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[tsan] Add a test for "external" API that checks the dup suppression is ↵Kuba Mracek
based on the caller PC We need to make sure that the "external" API isn't dup'ing all data races into a single one (because the stack might look the same) and suppressing all external races. This works now, so just adding a test for that. Differential Revision: https://reviews.llvm.org/D31734 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301011 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[tsan] Ignore memory accesses for libignored modules for "external" racesKuba Mracek
On Darwin, the setting ignore_noninstrumented_modules is used to suppress false positives in code that users don't have control of. The recently added "external" API (which can be used to detect races on objects provided by system libraries, but the race is actually user's fault) ignores this flag and it can report issues in non-instrumented modules. This patch fixes that. Differential Revision: https://reviews.llvm.org/D31553 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301000 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[tsan] Don't report bugs from interceptors called from libignored modulesKuba Mracek
This patch make sure we don't report deadlocks and other bug types when we're inside an interceptor that was called from a noninstrumented module (when ignore_noninstrumented_modules=1 is set). Adding a testcase that shows that deadlock detection still works on Darwin (to make sure we're not silencing too many reports). Differential Revision: https://reviews.llvm.org/D31449 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300998 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17[tsan] Add missing include for uint64_t in test.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300484 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17[sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek
We seem to assume that OS-provided thread IDs are either uptr or int, neither of which is true on Darwin. This introduces a tid_t type, which holds a OS-provided thread ID (gettid on Linux, pthread_threadid_np on Darwin, pthread_self on FreeBSD). Differential Revision: https://reviews.llvm.org/D31774 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300473 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10[tsan] Fall-back to IPv6 if IPv4 is not available.Vitaly Buka
Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D31897 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299885 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30[tsan] Add interceptor for xpc_connection_cancel to avoid false positivesKuba Mracek
TSan reports a false positive when using xpc_connection_cancel. We're missing a happens-before edge from xpc_connection_cancel to the event handler on the same connection. Differential Revision: https://reviews.llvm.org/D31475 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299086 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-27Add --std=c++11 to tests that #include <atomic>Sam McCall
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298836 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-26[tsan] Only Acquire/Release GCD queues if they're not NULLKuba Mracek
While it's usually a bug to call GCD APIs, such as dispatch_after, with NULL as a queue, this often "somehow" works and TSan should maintain binary compatibility with existing code. This patch makes sure we don't try to call Acquire and Release on NULL queues, and add one such testcase for dispatch_after. Differential Revision: https://reviews.llvm.org/D31355 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298820 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-26tsan: add new mutex annotationsDmitry Vyukov
There are several problems with the current annotations (AnnotateRWLockCreate and friends): - they don't fully support deadlock detection (we need a hook _before_ mutex lock) - they don't support insertion of random artificial delays to perturb execution (again we need a hook _before_ mutex lock) - they don't support setting extended mutex attributes like read/write reentrancy (only "linker init" was bolted on) - they don't support setting mutex attributes if a mutex don't have a "constructor" (e.g. static, Java, Go mutexes) - they don't ignore synchronization inside of lock/unlock operations which leads to slowdown and false negatives The new annotations solve of the above problems. See tsan_interface.h for the interface specification and comments. Reviewed in https://reviews.llvm.org/D31093 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-24Update debug_external.cc testcase to use TSan-invisible barriers to reduce ↵Kuba Mracek
flakiness. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298707 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-24Update the Darwin/external.cc testcase to use rpath. This means we can move ↵Kuba Mracek
the test output executables and still be able to run them. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298682 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21tsan: fix pie_no_aslr testDmitry Vyukov
It failed on clang-cmake-aarch64-39vma. Restrict it to x86_64 only. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298383 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21tsan: support __ATOMIC_HLE_ACQUIRE/RELEASE flagsDmitry Vyukov
HLE flags can be combined with memory order in atomic operations. Currently tsan runtime crashes on e.g. IsStoreOrder(mo) in atomic store if any of these additional flags are specified. Filter these flags out. See the comment as to why it is safe. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298378 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21tsan: add test for pie/no aslrDmitry Vyukov
Just ensure that such combination works. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298372 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22Re-commit of r295318, which was reverted due to AArch64 flakiness. Moving ↵Kuba Mracek
the test to Darwin only. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295801 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-20Revert "[tsan] Provide external tags (object types) via debugging API"Diana Picus
This reverts commit r295318 as the test is flaky on AArch64. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295667 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-16[tsan] Provide external tags (object types) via debugging APIKuba Mracek
In D28836, we added a way to tag heap objects and thus provide object types into report. This patch exposes this information into the debugging API. Differential Revision: https://reviews.llvm.org/D30023 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295318 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-13Fixup for r293885: Update external.cc testcase to include the forgotten ↵Kuba Mracek
stdlib.h. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295002 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02[powerpc] deactivate user_malloc.cc tsan test on powerpc64leBill Seurer
This test fails consistently on Ubuntu 16.xx powerpc64 LE systems. The cause is being investigated and in the meantime disable it so the buildbots can run cleanly. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293939 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02[tsan] Provide API for libraries for race detection on custom objectsKuba Mracek
This patch allows a non-instrumented library to call into TSan runtime, and tell us about "readonly" and "modifying" accesses to an arbitrary "object" and provide the caller and tag (type of object). This allows TSan to detect violations of API threading contracts where "read-only" methods can be called simulatenously from multiple threads, while modifying methods must be exclusive. Differential Revision: https://reviews.llvm.org/D28836 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293885 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02[tsan] Properly describe GCD worker threads in reportsKuba Mracek
When dealing with GCD worker threads, TSan currently prints weird things like "created by thread T-1" and "[failed to restore the stack]" in reports. This patch avoids that and instead prints "Thread T3 (...) is a GCD worker thread". Differential Revision: https://reviews.llvm.org/D29103 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293882 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-26[tsan] Fix os_id of main threadKuba Mracek
Currently, os_id of the main thread contains the PID instead of a thread ID. Let's fix this. Differential Revision: https://reviews.llvm.org/D29106 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293201 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24[tsan] Enable ignore_noninstrumented_modules=1 on Darwin by defaultKuba Mracek
TSan recently got the "ignore_noninstrumented_modules" flag, which disables tracking of read and writes that come from noninstrumented modules (via interceptors). This is a way of suppressing false positives coming from system libraries and other noninstrumented code. This patch turns this on by default on Darwin, where it's supposed to replace the previous solution, "ignore_interceptors_accesses", which disables tracking in *all* interceptors. The new approach should re-enable TSan's ability to find races via interceptors on Darwin. Differential Revision: https://reviews.llvm.org/D29041 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292981 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20[lit] Limit parallelism of sanitizer tests on Darwin [compiler-rt part, take 2]Kuba Mracek
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests. This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests. Differential Revision: https://reviews.llvm.org/D28420 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292549 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17Revert r292232.Kuba Mracek
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292236 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17[lit] Limit parallelism of sanitizer tests on Darwin [compiler-rt part]Kuba Mracek
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests. This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests. Differential Revision: https://reviews.llvm.org/D28420 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292232 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-11[tsan] Implement a 'ignore_noninstrumented_modules' flag to better suppress ↵Kuba Mracek
false positive races On Darwin, we currently use 'ignore_interceptors_accesses', which is a heavy-weight solution that simply turns of race detection in all interceptors. This was done to suppress false positives coming from system libraries (non-instrumented code), but it also silences a lot of real races. This patch implements an alternative approach that should allow us to enable interceptors and report races coming from them, but only if they are called directly from instrumented code. The patch matches the caller PC in each interceptors. For non-instrumented code, we call ThreadIgnoreBegin. The assumption here is that the number of instrumented modules is low. Most likely there's only one (the instrumented main executable) and all the other modules are system libraries (non-instrumented). Differential Revision: https://reviews.llvm.org/D28264 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291631 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06[sanitizer] Use architecture/slice information when symbolizing fat Mach-O ↵Kuba Mracek
files on Darwin This patch starts passing architecture information about a module to llvm-symbolizer and into text reports. This fixes the longstanding x86_64/x86_64h mismatch issue on Darwin. Differential Revision: https://reviews.llvm.org/D27390 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291287 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20Make this REQUIRES match the other REQUIRES lines that mention requiringChandler Carruth
a darwin system. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290152 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-19Fixup for r290119: Only run debug_alloc_stack.cc on Darwin until I figure ↵Kuba Mracek
out how to make it work on Linux. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290129 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-19More fixup for r290119: Make the ifdef work.Kuba Mracek
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290126 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-19Another fix-up for r290119: Include stdint.h so we have uint64_t on Linux.Kuba Mracek
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290124 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-19Fix-up for r290119 - don't check global size, it might not be available when ↵Kuba Mracek
using atos git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290123 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-19[tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query ↵Kuba Mracek
pointer types and allocation stacks of heap pointers In ASan, we have __asan_locate_address and __asan_get_alloc_stack, which is used in LLDB/Xcode to show the allocation backtrace for a heap memory object. This patch implements the same for TSan. Differential Revision: https://reviews.llvm.org/D27656 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290119 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-16Follow-up for r289831: Lower the unjoined thread count to 100 in the ↵Kuba Mracek
libcxx-future.mm testcase. Turns out 1000 unjoined threads are a bit too rough in certain environments. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289971 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15[tsan] Add interceptor for libcxx __shared_count::__release_shared()Kuba Mracek
We already have an interceptor for __shared_weak_count::__release_shared, this patch handles __shared_count::__release_shared in the same way. This should get rid of TSan false positives when using std::future. Differential Revision: https://reviews.llvm.org/D27797 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289831 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14tsan: allow Java VM iterate over allocated objectsDmitry Vyukov
Objects may move during the garbage collection, and JVM needs to notify ThreadAnalyzer about that. The new function __tsan_java_find eliminates the need to maintain these objects both in ThreadAnalyzer and JVM. Author: Alexander Smundak (asmundak) Reviewed in https://reviews.llvm.org/D27720 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289682 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29[sanitizer] Add macOS minimum deployment target to all compiler invocations ↵Kuba Mracek
in lit tests The Clang driver on macOS decides the deployment target based on various things, like your host OS version, the SDK version and some environment variables, which makes lit tests pass or fail based on your environment. Let's make sure we run all lit tests with `-mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}` (10.9 unless overriden). Differential Revision: https://reviews.llvm.org/D26929 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288186 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-26[tsan] Fix the lit expansion of %deflake not to eat a spaceKuba Mracek
The lit expansion of "%deflake " (notice the space after) expands in a way that the space is removed, this fixes that. Differential Revision: https://reviews.llvm.org/D27139 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287989 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-24[tsan] Add support for GCD dispatch_suspend and dispatch_resumeKuba Mracek
GCD queues can be suspended and resumed with dispatch_suspend and dispatch_resume. We need to add synchronization between the call to dispatch_resume and any subsequent executions of blocks in the queue that was resumed. We already have an Acquire(q) before the block executes, so this patch just adds the Release(q) in an interceptor of dispatch_resume. Differential Revision: https://reviews.llvm.org/D27112 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287902 91177308-0d34-0410-b5e6-96231b3b80d8