summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* tsan: support pie binaries on newer kernelsDmitry Vyukov2016-09-221-6/+0
| | | | | | | | | | | | | 4.1+ Linux kernels map pie binaries at 0x55: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d1fd836dcf00d2028c700c7e44d2c23404062c90 Currently tsan does not support app memory at 0x55 (https://github.com/google/sanitizers/issues/503). Older kernels also map pie binaries at 0x55 when ASLR is disables (most notably under gdb). This change extends tsan mapping for linux/x86_64 to cover 0x554-0x568 app range and fixes both 4.1+ kernels and gdb. This required to slightly shrink low and high app ranges and move heap. The mapping become even more non-linear, since now we xor lower bits. Now even a continuous app range maps to split, intermixed shadow ranges. This breaks ShadowToMemImpl as it assumes linear mapping at least within a continuous app range (however it turned out to be already broken at least on arm64/42-bit vma as uncovered by r281970). So also change ShadowToMemImpl to hopefully a more robust implementation that does not assume a linear mapping. llvm-svn: 282152
* [tsan] Update fork_atexit.cc to consistently print to stderr (and not stdout)Kuba Brecka2016-09-171-1/+1
| | | | llvm-svn: 281821
* [tsan] Update signal_cond.cc to write to stderr intead of stdoutKuba Brecka2016-09-171-1/+1
| | | | llvm-svn: 281820
* [tsan] Fix hanging gcd-apply and gcd-apply-race tests on macOS SierraKuba Brecka2016-09-142-0/+8
| | | | llvm-svn: 281462
* [tsan] Support C++11 call_once in TSan on DarwinKuba Brecka2016-09-081-0/+34
| | | | | | | | This patch adds a wrapper for call_once, which uses an already-compiled helper __call_once with an atomic release which is invisible to TSan. To avoid false positives, the interceptor performs an explicit atomic release in the callback wrapper. Differential Revision: https://reviews.llvm.org/D24188 llvm-svn: 280920
* [mips][tsan] XFAIL on every MIPS platform an x86_64-specific test.Vasileios Kalintiris2016-08-301-1/+1
| | | | | | | The map32bit.cc test uses the MMAP_32BIT flag which is supported only on x86-64. llvm-svn: 280084
* [TSan][MIPS] Implements setjmp assembly for MIPS64Sagar Thakur2016-08-166-16/+0
| | | | | | | Reviewed by dvyukov Differential: https://reviews.llvm.org/D23494 llvm-svn: 278775
* [sanitizers] Make it possible to XFAIL on the effective target, not just the ↵Daniel Sanders2016-08-097-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | default. Summary: The triple is not the right thing to XFAIL on since LIT only sees the default triple and not the effective triple chosen by any -target option in the RUN directives. This discrepancy is shown in the table below: Default Triple | Options | XFAIL | LIT's expected result | Desired expectation =================+===================================+========+=======================+==================== mips-linux-gnu | -target mips-linux-gnu | | Pass | Pass mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | | Pass | Pass mips-linux-gnu | -target mips-linux-gnu | mips | Fail | Fail mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips | Fail | Fail/Pass* (debatable**) mips-linux-gnu | -target mips-linux-gnu | mips- | Fail | Fail mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips- | Fail | Pass* mips-linux-gnu | -target mips-linux-gnu | mips64 | Pass | Pass mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips64 | Pass | Fail* mips64-linux-gnu | -target mips-linux-gnu | | Pass | Pass mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | | Pass | Pass mips64-linux-gnu | -target mips-linux-gnu | mips | Fail | Fail* mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips | Fail | Fail/Pass (debatable**) mips64-linux-gnu | -target mips-linux-gnu | mips- | Pass | Fail* mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips- | Pass | Pass mips64-linux-gnu | -target mips-linux-gnu | mips64 | Fail | Pass* mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips64 | Fail | Fail x64_64-linux-gnu | -target i386-linux-gnu | | Pass | Pass x64_64-linux-gnu | -target x86_64-linux-gnu | | Pass | Pass x64_64-linux-gnu | -target i386-linux-gnu | i386 | Pass | Fail* x64_64-linux-gnu | -target x86_64-linux-gnu | i386 | Pass | Pass x64_64-linux-gnu | -target i386-linux-gnu | x86_64 | Fail | Pass x64_64-linux-gnu | -target x86_64-linux-gnu | x86_64 | Fail | Fail* * These all differ from LIT's current behaviour. ** People's expectations vary depending on whether they know that LIT does a substring match on the default triple or think it's an exact match on an architecture. This patch adds "target-is-${target_arch}" to the available features list and updates the mips XFAIL's to use them. XFAIL'ing on these features will correctly account for the target being tested. Making the table: Options | XFAIL | LIT's expected result ==================================+==================+====================== -target mips-linux-gnu | | Pass -target mips64-linux-gnu -mabi=64 | | Pass -target mips-linux-gnu | target-is-mips | Fail -target mips64-linux-gnu -mabi=64 | target-is-mips | Pass -target mips-linux-gnu | target-is-mips64 | Pass -target mips64-linux-gnu -mabi=64 | target-is-mips64 | Fail -target i386-linux-gnu | | Pass -target x86_64-linux-gnu | | Pass -target i386-linux-gnu | target-is-i386 | Fail -target x86_64-linux-gnu | target-is-i386 | Pass -target i386-linux-gnu | target-is-x86_64 | Pass -target x86_64-linux-gnu | target-is-x86_64 | Fail Reviewers: probinson Subscribers: probinson, kubabrecka, llvm-commits, samsonov Differential Revision: https://reviews.llvm.org/D22802 llvm-svn: 278116
* [tsan] Fix the behavior of OSAtomicTestAndClearKuba Brecka2016-08-021-0/+34
| | | | | | | | The system implementation of OSAtomicTestAndClear returns the original bit, but the TSan interceptor has a bug which always returns zero from the function. This patch fixes this and adds a test. Differential Revision: https://reviews.llvm.org/D23061 llvm-svn: 277461
* [tsan] Fix behavior of realloc(nullptr, 0) on DarwinKuba Brecka2016-08-021-0/+20
| | | | | | | | On Darwin, there are some apps that rely on realloc(nullptr, 0) returning a valid pointer. TSan currently returns nullptr in this case, let's fix it to avoid breaking binary compatibility. Differential Revision: https://reviews.llvm.org/D22800 llvm-svn: 277458
* tsan: don't deliver signals when they are blockedDmitry Vyukov2016-07-271-0/+60
| | | | | | | | | | When we delay signals we can deliver them when the signal is blocked. This can be surprising to the program. Intercept signal blocking functions merely to process pending signals. As the result, at worst we will delay a signal till return from the signal blocking function. llvm-svn: 276876
* Disable the "gcd-io-race.mm" test to investigate bot hangs due to the test ↵Kuba Brecka2016-07-121-0/+2
| | | | | | being deadlocked. llvm-svn: 275182
* [compiler-rt] Fix VisualStudio virtual folders layoutEtienne Bergeron2016-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: This patch is a refactoring of the way cmake 'targets' are grouped. It won't affect non-UI cmake-generators. Clang/LLVM are using a structured way to group targets which ease navigation through Visual Studio UI. The Compiler-RT projects differ from the way Clang/LLVM are grouping targets. This patch doesn't contain behavior changes. Reviewers: kubabrecka, rnk Subscribers: wang0109, llvm-commits, kubabrecka, chrisha Differential Revision: http://reviews.llvm.org/D21952 llvm-svn: 275111
* [tsan] Add support for GCD IO channels on DarwinKuba Brecka2016-07-116-0/+390
| | | | | | | | This patch adds interceptors for dispatch_io_*, dispatch_read and dispatch_write functions. This avoids false positives when using GCD IO. Adding several test cases. Differential Revision: http://reviews.llvm.org/D21889 llvm-svn: 275071
* test: Use %clangxx in objc++ test filesSaleem Abdulrasool2016-07-097-7/+7
| | | | | | | | | | These test in this change are objc++, but are built using %clang, not %clangxx. The reason this works is the driver has been adding -lc++ for sanitizer enabled builds. By making these tests use %clangxx, they no longer depend on the driver linking to c++. Doing so will allow us to prevent overlinking of libc++ for applications. llvm-svn: 274989
* [tsan] Avoid false positives with GCD data callbacksKuba Brecka2016-07-071-0/+36
| | | | | | | | This patch adds synchronization between the creation of the GCD data object and destructor’s execution. It’s far from perfect, because ideally we’d want to synchronize the destruction of the last reference (via dispatch_release) and the destructor’s execution, but intercepting objc_release is problematic. Differential Revision: http://reviews.llvm.org/D21990 llvm-svn: 274749
* [tsan] Fix false positives with GCD dispatch_source_*Kuba Brecka2016-07-061-0/+33
| | | | | | | | We already have interceptors for dispatch_source API (e.g. dispatch_source_set_event_handler), but they currently only handle submission synchronization. We also need to synchronize based on the target queue (serial, concurrent), in other words, we need to use dispatch_callback_wrap. This patch implements that. Differential Revision: http://reviews.llvm.org/D21999 llvm-svn: 274619
* [tsan] Synchronize leaving a GCD group with notificationsKuba Brecka2016-07-051-0/+56
| | | | | | | | In the patch that introduced support for GCD barrier blocks, I removed releasing a group when leaving it (in dispatch_group_leave). However, this is necessary to synchronize leaving a group and a notification callback (dispatch_group_notify). Adding this back, simplifying dispatch_group_notify_f and adding a test case. Differential Revision: http://reviews.llvm.org/D21927 llvm-svn: 274549
* [tsan] dispatch_once interceptor will cause a crash/deadlock when the ↵Kuba Brecka2016-07-051-0/+41
| | | | | | | | | | original dispatch_once is used Because we use SCOPED_TSAN_INTERCEPTOR in the dispatch_once interceptor, the original dispatch_once can also be sometimes called (when ignores are enabled or when thr->is_inited is false). However the original dispatch_once function doesn’t expect to find “2” in the storage and it will spin forever (but we use “2” to indicate that the initialization is already done, so no waiting is necessary). This patch makes sure we never call the original dispatch_once. Differential Revision: http://reviews.llvm.org/D21976 llvm-svn: 274548
* [tsan] Relax the "ignored-interceptors.mm" testcase. The test has been ↵Kuba Brecka2016-07-011-1/+1
| | | | | | flaky because it's detecting a false positive race (coming from a system library) and sometimes that race is detected after we're printing "Done". llvm-svn: 274346
* [tsan] Stop extending the block’s lifetime in dispatch_group_asyncKuba Brecka2016-06-291-0/+43
| | | | | | | | The dispatch_group_async interceptor actually extends the lifetime of the executed block. This means the destructor of the block (and captured variables) is called *after* dispatch_group_leave, which changes the semantics of dispatch_group_async. This patch fixes that. Differential Revision: http://reviews.llvm.org/D21816 llvm-svn: 274117
* Adapt the "objc-race.mm" test to use ignore_interceptors_accesses=1. All ↵Kuba Brecka2016-06-281-1/+1
| | | | | | Obj-C/Darwin tests currently need this to avoid false positives. llvm-svn: 274014
* [tsan] Add HB edges for GCD barrier blocksKuba Brecka2016-06-272-0/+97
| | | | | | | | Adding support for GCD barrier blocks in concurrent queues. This uses two sync object in the same way as read-write locks do. This also simplifies the use of dispatch groups (the notifications act as barrier blocks). Differential Revision: http://reviews.llvm.org/D21604 llvm-svn: 273893
* [tsan] Intercept libcxx __release_shared to avoid false positive with ↵Kuba Brecka2016-06-263-0/+161
| | | | | | | | | | weak_ptrs and destructors in C++ There is a "well-known" TSan false positive when using C++ weak_ptr/shared_ptr and code in destructors, e.g. described at <https://llvm.org/bugs/show_bug.cgi?id=22324>. The "standard" solution is to build and use a TSan-instrumented version of libcxx, which is not trivial for end-users. This patch tries a different approach (on OS X): It adds an interceptor for the specific function in libc++.dylib, which implements the atomic operation that needs to be visible to TSan. Differential Revision: http://reviews.llvm.org/D21609 llvm-svn: 273806
* tsan: rely on AnnotateRWLockCreateStatic to detect linker-initialized mutexesDmitry Vyukov2016-06-032-0/+74
| | | | | | | | | The new annotation was added a while ago, but was not actually used. Use the annotation to detect linker-initialized mutexes instead of the broken IsGlobalVar which has both false positives and false negatives. Remove IsGlobalVar mess. llvm-svn: 271663
* tsan: clean up dynamic TLS memory between reuseDmitry Vyukov2016-06-021-0/+62
| | | | | | | | | | | | | Currently the added test produces false race reports with glibc 2.19, because DLTS memory is reused by pthread under the hood. Use the DTLS machinery to intercept new DTLS ranges. __tls_get_addr known to cause issues for tsan in the past, so write the interceptor more carefully. Reviewed in http://reviews.llvm.org/D20927 llvm-svn: 271568
* Init tsan with .preinit_array sectionVitaly Buka2016-05-261-0/+60
| | | | | | | | | | | | Summary: Some libraries, like OpenSSL, runs code from .init section. Reviewers: kcc, eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: http://reviews.llvm.org/D20646 llvm-svn: 270873
* [tsan] Change some OS X tests to include system headers (xpc.h, mman.h) more ↵Kuba Brecka2016-05-253-3/+7
| | | | | | explicitly. llvm-svn: 270713
* [tsan] Don't abort when a deadlock detector finds a mutex cycle longer than 10Kuba Brecka2016-05-211-0/+42
| | | | | | | | In one of the already existing apps that I'm testing TSan on, I really see a mutex path that is longer than 10 (but not by much, something like 11-13 actually). Let's raise this to 20 and weaken the assertion so we don't crash. Differential Revision: http://reviews.llvm.org/D20427 llvm-svn: 270319
* [tsan] Add support for GCD's dispatch_after and dispatch_after_fKuba Brecka2016-05-191-0/+41
| | | | | | | | We're missing interceptors for dispatch_after and dispatch_after_f. Let's add them to avoid false positives. Added a test case. Differential Revision: http://reviews.llvm.org/D20426 llvm-svn: 270071
* [tsan] Ensure mmap respects ignore_interceptors_accessesAnna Zaks2016-05-171-0/+61
| | | | | | | | | | | | | | | The ignore_interceptors_accesses setting did not have an effect on mmap, so let's change that. It helps in cases user code is accessing the memory written to by mmap when the synchronization is ensured by the code that does not get rebuilt. (This effects Swift interoperability since it's runtime is mapping memory which gets accessed by the code emitted into the Swift application by the compiler.) Differential Revision: http://reviews.llvm.org/D20294 llvm-svn: 269855
* tsan: fix another crash due to processorsDmitry Vyukov2016-05-101-0/+30
| | | | | | | | | | | | | | | | | | Another stack where we try to free sync objects, but don't have a processors is: // ResetRange // __interceptor_munmap // __deallocate_stack // start_thread // clone Again, it is a latent bug that lead to memory leaks. Also, increase amount of memory we scan in MetaMap::ResetRange. Without that the test does not fail, as we fail to free the sync objects on stack. llvm-svn: 269041
* tsan: fix a crashDmitry Vyukov2016-05-061-0/+39
| | | | | | | | | | | | | Fixes crash reported in: https://bugs.chromium.org/p/v8/issues/detail?id=4995 The problem is that we don't have a processor in a free interceptor during thread exit. The crash was introduced by introduction of Processors. However, previously we silently leaked memory which wasn't any better. llvm-svn: 268782
* [tsan] Return 0 from malloc_size for non-malloc'd pointersKuba Brecka2016-04-301-11/+43
| | | | | | | | In http://reviews.llvm.org/D19100, I introduced a bug: On OS X, existing programs rely on malloc_size() to detect whether a pointer comes from heap memory (malloc_size returns non-zero) or not. We have to distinguish between a zero-sized allocation (where we need to return 1 from malloc_size, due to other binary compatibility reasons, see http://reviews.llvm.org/D19100), and pointers that are not returned from malloc at all. Differential Revision: http://reviews.llvm.org/D19653 llvm-svn: 268157
* [tsan] Rename ReportThread->pid to ReportThread->os_idKuba Brecka2016-04-211-4/+4
| | | | | | | | The field "pid" in ReportThread is used to store the OS-provided thread ID (pthread_self or gettid). The name "pid" suggests it's a process ID, which it isn't. Let's rename it. Differential Revision: http://reviews.llvm.org/D19365 llvm-svn: 266994
* [compiler-rt] Remove unwanted --check-prefix=CHECK from unit tests. NFC.Mandeep Singh Grang2016-04-191-1/+1
| | | | | | | | | | | | | | | Summary: Removed unwanted --check-prefix=CHECK from the following unit tests: test/asan/TestCases/Posix/start-deactivated.cc test/tsan/Darwin/ignored-interceptors.mm Patch by: Mandeep Singh Grang (mgrang) Reviewers: samsonov, kcc, dvyukov, eugenis Differential Revision: http://reviews.llvm.org/D19281 llvm-svn: 266813
* Replace hardcoded comment at 'lit.site.cfg.in'Alex Denisov2016-04-162-4/+2
| | | | | | | | | | | | At the moment almost every lit.site.cfg.in contains two lines comment: ## Autogenerated by LLVM/Clang configuration. # Do not edit! The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from configure_lit_site_cfg with the note and some useful information. llvm-svn: 266520
* [TSAN] Make tsan tests more portable (take 3)Renato Golin2016-04-1551-73/+73
| | | | | | | | Some tests didn't merge stderr with stdout. Patch by Maxim Kuvyrkov. llvm-svn: 266426
* Revert "Make tsan tests more portable (take 2)"Renato Golin2016-04-1451-63/+63
| | | | | | This reverts commit r266294, as it broke some buildbots again. :/ llvm-svn: 266300
* Make tsan tests more portable (take 2)Renato Golin2016-04-1451-63/+63
| | | | | | | | | Using stderr more uniformily, avoiding potential races when scanning stdout and stderr output. Patch by Maxim Kuvyrkov. llvm-svn: 266294
* [tsan] Fix size reporting for OS X zone allocator with 0-sized allocationsKuba Brecka2016-04-141-0/+23
| | | | | | | | The custom zone implementation for OS X must not return 0 (even for 0-sized allocations). Returning 0 indicates that the pointer doesn't belong to the zone. This can break existing applications. The underlaying allocator allocates 1 byte for 0-sized allocations anyway, so returning 1 in this case is okay. Differential Revision: http://reviews.llvm.org/D19100 llvm-svn: 266283
* [tsan] Replace 'not' with '%deflake' in gcd-apply-race.mm Darwin test.Kuba Brecka2016-04-111-1/+1
| | | | llvm-svn: 265919
* [tsan] Remove long sleeps from fork testsKuba Brecka2016-04-072-10/+2
| | | | | | | | On one of our testing machines, we're running the tests under heavy load, and especially in the fork-based TSan tests, we're seeing timeouts when a test uses sleep(10), assuming that calling fork() on another thread will finish sooner than that. This patch removes a timeout and makes another one longer. Differential Revision: http://reviews.llvm.org/D18476 llvm-svn: 265666
* [tsan] Add support for OS X OSAtomic* functionsKuba Brecka2016-04-072-0/+91
| | | | | | | | OS X provides atomic functions in libkern/OSAtomic.h. These provide atomic guarantees and they have alternatives which have barrier semantics. This patch adds proper TSan support for the functions from libkern/OSAtomic.h. Differential Revision: http://reviews.llvm.org/D18500 llvm-svn: 265665
* [tsan] Add interceptors for dispatch_applyKuba Brecka2016-04-072-0/+70
| | | | | | | | Adding an interceptor with two more release+acquire pairs to avoid false positives with dispatch_apply. Differential Revision: http://reviews.llvm.org/D18722 llvm-svn: 265662
* [tsan] Add XPC support (OS X)Kuba Brecka2016-04-072-0/+153
| | | | | | | | XPC APIs have async callbacks, and we need some more happen-before edges to avoid false positives. This patch add them, plus a test case (sorry for the long boilerplate code, but XPC just needs all that). Differential Revision: http://reviews.llvm.org/D18493 llvm-svn: 265661
* [tsan] Add support for dispatch event sourcesKuba Brecka2016-04-076-0/+214
| | | | | | | | GCD has APIs for event sources, we need some more release-acquire pairs to avoid false positives in TSan. Differential Revision: http://reviews.llvm.org/D18515 llvm-svn: 265660
* [tsan] Fix synchronization in dispatch_syncKuba Brecka2016-04-071-0/+34
| | | | | | | | In the interceptor for dispatch_sync, we're currently missing synchronization between the callback and the code *after* the call to dispatch_sync. This patch fixes this by adding an extra release+acquire pair to dispatch_sync() and similar APIs. Added a testcase. Differential Revision: http://reviews.llvm.org/D18502 llvm-svn: 265659
* [tsan] Fix Darwin tests (missing FileCheck's)Kuba Brecka2016-04-0711-16/+16
| | | | | | | | A little embarrassing, but we're missing the call to FileCheck in several Darwin tests. Let's fix this. Differential Revision: http://reviews.llvm.org/D18503 llvm-svn: 265658
* [asan,tsan] Make Darwin-specific tests more stable (use ↵Kuba Brecka2016-04-0411-17/+16
| | | | | | ignore_interceptors_accesses=1 for GCD tests and printf instead of NSLog). llvm-svn: 265300
OpenPOWER on IntegriCloud