summaryrefslogtreecommitdiff
path: root/test/tsan
AgeCommit message (Collapse)Author
2017-11-27[TSan] Do not run cond_cancel.c test on ppc64.Matt Morehouse
After r319004, the expected failure on ppc64 manifests as an infinite loop. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319114 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-16Implement GetTls() for NetBSDKamil Rytarowski
Summary: Reuse the existing code for FreeBSD that is compatible with NetBSD. Add NetBSD support in tests: tls_race.cc and tls_race2.cc. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, vitalybuka, kcc, eugenis Reviewed By: dvyukov Subscribers: srhines, emaste, kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40105 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08Correct atexit(3) support in TSan/NetBSDKamil Rytarowski
Summary: The NetBSD specific implementation of cxa_atexit() does not preserve the 2nd argument if dso is equal to NULL. Changes: - Split paths of handling intercepted __cxa_atexit() and atexit(3). This affects all supported Operating Systems. - Add a local stack-like structure to hold the __cxa_atexit() context. atexit(3) is documented in the C standard as calling callback from the earliest to the oldest entry. This path also fixes potential ABI problem of passing an argument to a function from the atexit(3) callback mechanism. - Add new test to ensure LIFO style of atexit(3) callbacks: atexit3.cc Proposal to change the behavior of __cxa_atexit() in NetBSD has been rejected. With the above changes TSan/NetBSD with the current tsan_interceptors.cc can bootstrap into operation. Sponsored by <The NetBSD Foundation> Reviewers: vitalybuka, dvyukov, joerg, kcc, eugenis Reviewed By: dvyukov Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39619 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317735 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25Add NetBSD improvements in sanitizersKamil Rytarowski
Summary: Changes: * Add initial msan stub support. * Handle NetBSD specific pthread_setname_np(3). * NetBSD supports __attribute__((tls_model("initial-exec"))), define it in SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE. * Add ReExec() specific bits for NetBSD. * Simplify code and add syscall64 and syscall_ptr for !NetBSD. * Correct bunch of syscall wrappers for NetBSD. * Disable test/tsan/map32bit on NetBSD as not applicable. * Port test/tsan/strerror_r to a POSIX-compliant OSes. * Disable __libc_stack_end on NetBSD. * Disable ReadNullSepFileToArray() on NetBSD. * Define struct_ElfW_Phdr_sz, detected missing symbol by msan. * Change type of __sanitizer_FILE from void to char. This helps to reuse this type as an array. Long term it will be properly implemented along with SANITIZER_HAS_STRUCT_FILE setting to 1. * Add initial NetBSD support in lib/tsan/go/buildgo.sh. * Correct referencing stdout and stderr in tsan_interceptors.cc on NetBSD. * Document NetBSD x86_64 specific virtual memory layout in tsan_platform.h. * Port tests/rtl/tsan_test_util_posix.cc to NetBSD. * Enable NetBSD tests in test/msan/lit.cfg. * Enable NetBSD tests in test/tsan/lit.cfg. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, eugenis, kcc, dvyukov Reviewed By: dvyukov Subscribers: #sanitizers, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39124 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316591 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-20tsan: add tests missed in r316209Dmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316210 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-20[tsan] Add Mutex annotation flag for constant-initialized ↵Dmitry Vyukov
__tsan_mutex_linker_init behavior Add a new flag, _⁠_tsan_mutex_not_static, which has the opposite sense of _⁠_tsan_mutex_linker_init. When the new _⁠_tsan_mutex_not_static flag is passed to _⁠_tsan_mutex_destroy, tsan ignores the destruction unless the mutex was also created with the _⁠_tsan_mutex_not_static flag. This is useful for constructors that otherwise woud set _⁠_tsan_mutex_linker_init but cannot, because they are declared constexpr. Google has a custom mutex with two constructors, a "linker initialized" constructor that relies on zero-initialization and sets ⁠_⁠_tsan_mutex_linker_init, and a normal one which sets no tsan flags. The "linker initialized" constructor is morally constexpr, but we can't declare it constexpr because of the need to call into tsan as a side effect. With this new flag, the normal c'tor can set _⁠_tsan_mutex_not_static, the "linker initialized" constructor can rely on tsan's lazy initialization, and _⁠_tsan_mutex_destroy can still handle both cases correctly. Author: Greg Falcon (gfalcon) Reviewed in: https://reviews.llvm.org/D39095 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316209 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-11Disable TSan tests on Android.Evgeniy Stepanov
They never passed. This change excludes them from 'check-all'. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315512 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-10Factor out "stable-runtime" feature and enable it on all android.Evgeniy Stepanov
This is a very poorly named feature. I think originally it meant to cover linux only, but the use of it in msan seems to be about any aarch64 platform. Anyway, this change should be NFC on everything except Android. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315389 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28tsan: handle signals in pause callDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314384 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22Deflake the "xpc-race.mm" test.Kuba Mracek
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314014 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-12[tsan] Disable user_malloc test which fails glibc 2.24Vitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313069 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-30Add NetBSD support in test/tsan/thread_name*.ccKamil Rytarowski
Summary: A snipped from the documentation of thread_setname_np(3): NAME pthread_getname_np - get and set descriptive name of a thread LIBRARY POSIX Threads Library (libpthread, -lpthread) SYNOPSIS #include <pthread.h> int pthread_getname_np(pthread_t thread, char *name, size_t len); int pthread_setname_np(pthread_t thread, const char *name, void *arg); Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc Reviewed By: dvyukov Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D37306 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312159 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-25tsan: fix darwin buildDmitry Vyukov
Runtime hooks do not seem to work on darwin. The test failed on builder: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/34882/consoleFull#7286766538254eaf0-7326-4999-85b0-388101f2d404 Move the test to Linux dir. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311776 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-25tsan: don't pass bogus PCs to __tsan_symbolize_externalDmitry Vyukov
See the added comment for an explanation. Reviewed in https://reviews.llvm.org/D37107 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311768 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24[Sanitizers] TSan allocator set errno on failure.Alex Shlyapnikov
Summary: Set proper errno code on allocation failures and change realloc, pvalloc, aligned_alloc, memalign and posix_memalign implementation to satisfy their man-specified requirements. Modify allocator API implementation to bring it closer to other sanitizers allocators. Reviewers: dvyukov Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D35690 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308929 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-16[tsan] Disable test with debug runtimeVitaly Buka
Test expects at least -O1 compiled runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308121 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-12Add explicit CMake targets for ASan/TSan iOS Simulator testing and update ↵Kuba Mracek
the instructions how to run them. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307844 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-12tsan: add test for __tsan_java_findDmitry Vyukov
The test should have been added in 289682 "tsan: allow Java VM iterate over allocated objects" but I forgot to avn add. Author: Alexander Smundak (asmundak) Reviewed in https://reviews.llvm.org/D27720 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307776 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10Fix-up for r307537: We need to #include stdint.h to get int32_t.Kuba Mracek
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307557 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10Fixup whitespace.Kuba Mracek
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307538 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10[tsan] Add support for running TSan tests on iOS simulator and devicesKuba Mracek
Differential Revision: https://reviews.llvm.org/D35157 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307537 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05[tsan] Use pthread_sigmask instead of sigprocmask to block signals in a ↵Kuba Mracek
thread on Darwin On Darwin, sigprocmask changes the signal mask for the entire process. This has some unwanted consequences, because e.g. internal_start_thread wants to disable signals only in the current thread (to make the new thread inherit the signal mask), which is currently broken on Darwin. This patch switches to pthread_sigmask. Differential Revision: https://reviews.llvm.org/D35016 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307212 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-03fix trivial typos in comments; NFCHiroshi Inoue
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307005 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-28[Sanitizers] Operator new() interceptors always die on allocation errorAlex Shlyapnikov
Summary: Operator new interceptors behavior is now controlled by their nothrow property as well as by allocator_may_return_null flag value: - allocator_may_return_null=* + new() - die on allocation error - allocator_may_return_null=0 + new(nothrow) - die on allocation error - allocator_may_return_null=1 + new(nothrow) - return null Ideally new() should throw std::bad_alloc exception, but that is not trivial to achieve, hence TODO. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34731 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306604 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13tsan: fix reading of mutex flagsDmitry Vyukov
SyncVar::IsFlagSet returns true if any flag is set. This is wrong. Check the actual requested flag. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305281 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07Mark the tsan strerror_r test as unsupported on DarwinVedant Kumar
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304944 91177308-0d34-0410-b5e6-96231b3b80d8
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