summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/Darwin
Commit message (Collapse)AuthorAgeFilesLines
* [TSan] Pacify flaky test on DarwinJulian Lettner2019-12-111-7/+18
| | | | | | | | | | | This flaky test that I added really gives our CI a lot of headaches. Although I was never able to reproduce this locally, it sporadically hangs/fails on our bots. I decided to silently pass the test whenever we are unable to setup the proper test condition after 10 retries. This is of course suboptimal and a last recourse. Please let me know if you know how to test this better. rdar://57844626
* [TSan] Make `mach_vm_allocate.c` test less flakyJulian Lettner2019-11-211-5/+8
| | | | rdar://57365733
* [TSan] Add AnnotateIgnoreReadsBegin declaration to tsan/test.hJulian Lettner2019-09-091-5/+0
| | | | | | | | | | | | Declare the family of AnnotateIgnore[Read,Write][Begin,End] TSan annotations in compiler-rt/test/tsan/test.h so that we don't have to declare them separately in every test that needs them. Replace usages. Leave usages that explicitly test the annotation mechanism: thread_end_with_ignore.cpp thread_end_with_ignore3.cpp llvm-svn: 371446
* [TSan] Add interceptors for mach_vm_[de]allocateJulian Lettner2019-09-091-0/+73
| | | | | | | | | | | | I verified that the test is red without the interceptors. rdar://40334350 Reviewed By: kubamracek, vitalybuka Differential Revision: https://reviews.llvm.org/D66616 llvm-svn: 371439
* [TSan] Add interceptors for os_unfair_lockJulian Lettner2019-08-161-0/+30
| | | | llvm-svn: 369164
* compiler-rt: Rename .cc file in test/tsan to .cppFangrui Song2019-08-0215-5/+5
| | | | | | Like r367463, but for test/tsan. llvm-svn: 367656
* [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.*Reid Kleckner2019-06-271-0/+0
| | | | | | | | | | | | | These lit configuration files are really Python source code. Using the .py file extension helps editors and tools use the correct language mode. LLVM and Clang already use this convention for lit configuration, this change simply applies it to all of compiler-rt. Reviewers: vitalybuka, dberris Differential Revision: https://reviews.llvm.org/D63658 llvm-svn: 364591
* [TSan][libdispatch] Port gcd-sync-block-copy.mm to C++Julian Lettner2019-04-161-3/+7
| | | | | | | | | | | | | | | | | | | | | | | Summary: Apparently, it makes a difference on where a block lives depending on if it's passed "inline" versus assigned and then passed via a variable. Both tests in this commit now give a signal, if `Block_copy` is used in `dispatch_sync`. Since these tests use different mechanisms (Objective-C retain versus C++ copy constructor) as proxies to observe if the block was copied, we should keep both of them. Commit, that first avoided the unnecessary copy: faef7d034a9ec6cb757137adce8e8670ec6c2d7b Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D60639 llvm-svn: 358469
* [TSan][libdispatch] Move libdispatch tests out of Darwin folderJulian Lettner2019-04-1223-1071/+0
| | | | | | | The libdispatch tests are now not tied to Darwin anymore. Move them to their own platform-independent folder. llvm-svn: 358316
* [TSan][libdispatch] Don't link against FoundationJulian Lettner2019-04-126-13/+22
| | | | | | | Now that our tests don't depend on Foundation anymore, don't link it in. llvm-svn: 358309
* [TSan][libdispatch] Replace NSTemporaryDirectory in testsJulian Lettner2019-04-126-13/+8
| | | | | | | | | | | | | After this change, most tests don't have a dependency on Foundation. Note: To hold the file name `tempnam` allocates a new buffer. We leak this buffer (omit the free), but I don't think we need to care. Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D60591 llvm-svn: 358308
* [TSan][libdispatch] Delete old testsJulian Lettner2019-04-112-69/+0
| | | | | | | | | | In a previous commit, I re-enabled the ported variants of these 2 tests: tsan/Darwin/gcd-data.mm -> tsan/libdispatch/data.c tsan/Darwin/gcd-source-serial.mm -> tsan/libdispatch/source-serial.c So now we can delete the Darwin-only version. llvm-svn: 358235
* [TSan][libdispatch] Replace usage of NSMutableData with stack arrayJulian Lettner2019-04-115-10/+10
| | | | | | | | Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D60477 llvm-svn: 358205
* [TSan][libdispatch] Change test to have two simultaneous timersJulian Lettner2019-04-111-1/+1
| | | | | | | | | | | Change test semantics by waiting for both timer callbacks at the end instead of serializing operations: start/wait timer 1 then 2. Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D60476 llvm-svn: 358204
* [TSan][libdispatch] Replace CFRunLoop with dispatch_semaphore, pt. 2Julian Lettner2019-04-1111-83/+97
| | | | | | | | Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D60475 llvm-svn: 358203
* [TSan][libdispatch] Replace CFRunLoop with dispatch_semaphore, pt. 1Julian Lettner2019-04-096-53/+54
| | | | | | | | | | | | Remove the dependency on Foundation so we can start running those tests on other platforms. Rename/move of tests will be done in a separate commit. Reviewed By: kubamracek, dvyukov Differential Revision: https://reviews.llvm.org/D60347 llvm-svn: 358023
* [TSan][libdispatch] Remove Darwin-only version of fully-ported testsJulian Lettner2019-04-0610-428/+0
| | | | | | | Remove 10 tests that already have a copy in tsan/libdispatch, without dependencies on Darwin-specifis. llvm-svn: 357832
* [TSan] Remove ignore_interceptors_accesses flagJulian Lettner2019-01-102-56/+4
| | | | | | | | | | | | | | | | | | | | | | Summary: It has been superseded by the `ignore_noninstrumented_modules` flag and is no longer needed. Also simplify a test that checks that `mmap_interceptor` respects ignore annotations (`thr->ignore_reads_and_writes `). Relevant: https://reviews.llvm.org/rL269855 <rdar://problem/46263073> Remove obsolete Apple-specific suppression option Reviewers: dcoughlin, kubamracek, dvyukov, delcypher Reviewed By: dvyukov Subscribers: jfb, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55075 llvm-svn: 350883
* [TSan] Support Objective-C @synchronized with tagged pointersJulian Lettner2019-01-071-2/+1
| | | | | | | | | | | | | | | | | | | Summary: Objective-C employs tagged pointers, that is, small objects/values may be encoded directly in the pointer bits. The resulting pointer is not backed by an allocation/does not point to a valid memory. TSan infrastructure requires a valid address for `Acquire/Release` and `Mutex{Lock/Unlock}`. This patch establishes such a mapping via a "dummy allocation" for each encountered tagged pointer value. Reviewers: dcoughlin, kubamracek, dvyukov, delcypher Reviewed By: dvyukov Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D56238 llvm-svn: 350556
* [TSan] Enable detection of lock-order-inversions for Objective-C @synchronizedJulian Lettner2019-01-023-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: @synchronized semantics can be synthesized by using existing mutex_[un]lock operations. ``` @synchronized(obj) { // ... } => { mutex_lock(obj); // ... mutex_unlock(obj); } ``` Let me know whether you think this a good idea. Reviewers: dcoughlin, dvyukov, kubamracek, delcypher Reviewed By: dvyukov Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55959 llvm-svn: 350258
* [tsan] Avoid calling Block_copy in the "sync" GCD interceptorsKuba Mracek2018-08-211-0/+34
| | | | | | | | | | The synchronous dispatch functions in GCD (dispatch_sync, dispatch_barrier_sync), don't make a copy of the passed block. To maintain binary compatibility, we should avoid doing that as well in TSan, as there's no reason to do that. The synchronous dispatch functions will not return before the block is actually executed. rdar://problem/42242579 Differential Revision: https://reviews.llvm.org/D50920 llvm-svn: 340342
* [tsan] Fix crash in objc_sync_enter/objc_sync_exit when using an Obj-C ↵Kuba Mracek2018-07-241-0/+62
| | | | | | | | | | tagged pointer Objective-C tagged pointers (either bottom-most or top-most bit is 1) are valid Obj-C objects but are not valid pointers. Make sure we don't crash on them when used in objc_sync_enter/objc_sync_exit. Instead, let's synchronize on a global object. Differential Revision: https://reviews.llvm.org/D49707 llvm-svn: 337837
* Remove `tsan/Darwin/gcd-after-null.mm` test.Dan Liew2018-07-131-23/+0
| | | | | | | | | | | | | | | | | Summary: This test invokes undocumented behaviour that could change in the future. Given this, it's probably best to just remove the test. rdar://problem/42022283 Reviewers: kubamracek Subscribers: llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D49269 llvm-svn: 336977
* [tsan] Add debugging API to retrieve the "external tag" from reportsKuba Mracek2018-05-101-0/+68
| | | | | | Differential Revision: https://reviews.llvm.org/D46661 llvm-svn: 332048
* Revert "Follow-up to r331378. Update tests to allow to use C atomics in C++."Volodymyr Sapsai2018-05-033-3/+3
| | | | | | | | | | | | | It reverts commit r331484 because it caused test failures ThreadSanitizer-x86_64 :: Darwin/gcd-groups-destructor.mm ThreadSanitizer-x86_64 :: Darwin/libcxx-shared-ptr-stress.mm ThreadSanitizer-x86_64 :: Darwin/xpc-race.mm Foundation.h transitively includes <atomic>, so we have a case of benign mixing <stdatomic.h> and <atomic>. llvm-svn: 331491
* Follow-up to r331378. Update tests to allow to use C atomics in C++.Volodymyr Sapsai2018-05-033-3/+3
| | | | | | | | | | | | Reviewers: kubamracek Reviewed By: kubamracek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46363 llvm-svn: 331484
* [tsan] Add interceptors for objc_sync_enter and objc_sync_exitKuba Mracek2018-04-131-0/+57
| | | | | | | | Objective-C's @synchronize synchronization primitive uses calls to objc_sync_enter and objc_sync_exit runtime functions. In most cases, they end up just calling pthread_mutex_lock/pthread_mutex_unlock, but there are some cases where the synchronization from pthread_mutex_lock/pthread_mutex_unlock interceptors isn't enough. Let's add explicit interceptors for objc_sync_enter and objc_sync_exit to handle all cases. Differential Revision: https://reviews.llvm.org/D45487 llvm-svn: 329982
* Fix which Darwin versions have ObjC runtime with full subscripting support.Volodymyr Sapsai2018-02-261-1/+1
| | | | | | | | | | | | | | | | | Update min deployment target in some tests so that they don't try to link against libarclite and don't fail when it's not available. rdar://problem/29253617 Reviewers: vsk, kubamracek Reviewed By: vsk Subscribers: jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43787 llvm-svn: 326143
* Deflake the "xpc-race.mm" test.Kuba Mracek2017-09-221-22/+31
| | | | llvm-svn: 314014
* Fix-up for r307537: We need to #include stdint.h to get int32_t.Kuba Mracek2017-07-101-0/+1
| | | | llvm-svn: 307557
* [tsan] Add support for running TSan tests on iOS simulator and devicesKuba Mracek2017-07-105-4/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D35157 llvm-svn: 307537
* [tsan] Use pthread_sigmask instead of sigprocmask to block signals in a ↵Kuba Mracek2017-07-051-0/+75
| | | | | | | | | | 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 llvm-svn: 307212
* fix trivial typos in comments; NFCHiroshi Inoue2017-07-032-2/+2
| | | | llvm-svn: 307005
* [tsan] Detect races on modifying accesses in Swift codeKuba Mracek2017-05-033-8/+102
| | | | | | | | 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 llvm-svn: 302050
* TSan: update line number after XFAIL on iOS.Tim Northover2017-04-271-2/+2
| | | | llvm-svn: 301560
* XFAIL the TSan XPC tests on iOS. XPC isn't available on iOS.Kuba Mracek2017-04-263-0/+6
| | | | llvm-svn: 301459
* [tsan] Include __tsan_external_* API from a header file instead of declaring ↵Kuba Mracek2017-04-242-10/+0
| | | | | | | | them manually. NFC. Differential Revision: https://reviews.llvm.org/D32384 llvm-svn: 301190
* [tsan] Remove the extra word "object" from description of external racesKuba Mracek2017-04-241-6/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D32383 llvm-svn: 301189
* [tsan] Add a test for "external" API that checks the dup suppression is ↵Kuba Mracek2017-04-211-0/+66
| | | | | | | | | | 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 llvm-svn: 301011
* [tsan] Ignore memory accesses for libignored modules for "external" racesKuba Mracek2017-04-214-63/+117
| | | | | | | | 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 llvm-svn: 301000
* [tsan] Don't report bugs from interceptors called from libignored modulesKuba Mracek2017-04-211-0/+47
| | | | | | | | 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 llvm-svn: 300998
* [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek2017-04-171-2/+2
| | | | | | | | 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 llvm-svn: 300473
* [tsan] Add interceptor for xpc_connection_cancel to avoid false positivesKuba Mracek2017-03-301-0/+37
| | | | | | | | 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 llvm-svn: 299086
* [tsan] Only Acquire/Release GCD queues if they're not NULLKuba Mracek2017-03-261-0/+23
| | | | | | | | 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 llvm-svn: 298820
* Update debug_external.cc testcase to use TSan-invisible barriers to reduce ↵Kuba Mracek2017-03-241-0/+5
| | | | | | flakiness. llvm-svn: 298707
* Update the Darwin/external.cc testcase to use rpath. This means we can move ↵Kuba Mracek2017-03-241-3/+12
| | | | | | the test output executables and still be able to run them. llvm-svn: 298682
* Re-commit of r295318, which was reverted due to AArch64 flakiness. Moving ↵Kuba Mracek2017-02-221-0/+61
| | | | | | the test to Darwin only. llvm-svn: 295801
* Fixup for r293885: Update external.cc testcase to include the forgotten ↵Kuba Mracek2017-02-131-0/+1
| | | | | | stdlib.h. llvm-svn: 295002
* [tsan] Provide API for libraries for race detection on custom objectsKuba Mracek2017-02-021-0/+153
| | | | | | | | 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 llvm-svn: 293885
* [tsan] Properly describe GCD worker threads in reportsKuba Mracek2017-02-021-0/+43
| | | | | | | | 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 llvm-svn: 293882
OpenPOWER on IntegriCloud