summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* [TSan] Adjust expectation for check_analyze.shCraig Topper2017-04-061-9/+3
| | | | | | | | r299658 fixed a case where InstCombine was replicating instructions instead of combining. Fixing this reduced the number of pushes and pops in the __tsan_read and __tsan_write functions. Adjust the expectations to account for this after talking to Dmitry Vyukov. llvm-svn: 299661
* [tsan] Add interceptor for xpc_connection_cancel to avoid false positivesKuba Mracek2017-03-301-0/+6
| | | | | | | | 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
* [sanitizer] Move fread and fwrite interceptors to sanitizer_commonMaxim Ostapenko2017-03-301-18/+0
| | | | | | | | {M, T, E}San have fread and fwrite interceptors, let's move them to sanitizer_common to enable ASan checks as well. Differential Revision: https://reviews.llvm.org/D31456 llvm-svn: 299061
* [tsan] Only Acquire/Release GCD queues if they're not NULLKuba Mracek2017-03-261-8/+9
| | | | | | | | 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
* tsan: add new mutex annotationsDmitry Vyukov2017-03-2615-109/+324
| | | | | | | | | | | | | | 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 llvm-svn: 298809
* Follow-up for r298738: Use "0" instead of "false" because the variable is uptr.Kuba Mracek2017-03-241-1/+1
| | | | llvm-svn: 298741
* Fix an uninitialized field in tsan_block_context_t/AllocContext in ↵Kuba Mracek2017-03-241-0/+1
| | | | | | tsan_libdispatch_mac.cc. llvm-svn: 298738
* tsan: fix a typoDmitry Vyukov2017-03-221-2/+2
| | | | | | s/covert_morder/convert_morder/ llvm-svn: 298492
* tsan: support __ATOMIC_HLE_ACQUIRE/RELEASE flagsDmitry Vyukov2017-03-211-1/+18
| | | | | | | | | | | 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. llvm-svn: 298378
* Re-commit of r295318, which was reverted due to AArch64 flakiness. Moving ↵Kuba Mracek2017-02-222-0/+14
| | | | | | the test to Darwin only. llvm-svn: 295801
* Revert "[tsan] Provide external tags (object types) via debugging API"Diana Picus2017-02-202-14/+0
| | | | | | This reverts commit r295318 as the test is flaky on AArch64. llvm-svn: 295667
* [tsan] Provide external tags (object types) via debugging APIKuba Mracek2017-02-162-0/+14
| | | | | | | | 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 llvm-svn: 295318
* [tsan] Provide API for libraries for race detection on custom objectsKuba Mracek2017-02-0211-12/+136
| | | | | | | | 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-029-11/+19
| | | | | | | | 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
* [tsan] Fix os_id of main threadKuba Mracek2017-01-261-1/+1
| | | | | | | | 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 llvm-svn: 293201
* [tsan] Enable ignore_noninstrumented_modules=1 on Darwin by defaultKuba Mracek2017-01-241-1/+1
| | | | | | | | 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 llvm-svn: 292981
* Revert "[sancov] moving sancov rt to sancov/ directory"Mike Aizatsky2017-01-123-5/+0
| | | | | | | | This reverts commit https://reviews.llvm.org/rL291734 Reason: mac breakage http://lab.llvm.org:8080/green//job/clang-stage1-configure-RA_build/28798/consoleFull#1657087648e9a0fee5-ebcc-4238-a641-c5aa112c323e llvm-svn: 291736
* [sancov] moving sancov rt to sancov/ directoryMike Aizatsky2017-01-123-0/+5
| | | | | | | | Subscribers: kubabrecka, mgorny Differential Revision: https://reviews.llvm.org/D28541 llvm-svn: 291734
* [tsan] Implement a 'ignore_noninstrumented_modules' flag to better suppress ↵Kuba Mracek2017-01-113-34/+33
| | | | | | | | | | | | | | 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 llvm-svn: 291631
* Make cmake link flag naming consistentFrancis Ricci2017-01-102-6/+6
| | | | | | | | | | | | | | | | | | | Summary: The build system was inconsistent in its naming conventions for link flags. This patch changes all uses of LINKFLAGS to LINK_FLAGS, for consistency with cmake's LINK_FLAGS property. This patch should make it easier to search the source code for uses of link flags, as well as providing the benefit of improved style and consistency. Reviewers: compnerd, beanz Subscribers: kubabrecka, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D28506 llvm-svn: 291539
* Enable weak hooks on darwinFrancis Ricci2017-01-092-2/+11
| | | | | | | | | | | | | | | | Summary: By default, darwin requires a definition for weak interface functions at link time. Adding the '-U' link flag with each weak function allows these weak interface functions to be used without definitions, which mirrors behavior on linux and windows. Reviewers: compnerd, eugenis Subscribers: kubabrecka, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D28203 llvm-svn: 291417
* tsan: Introducing a function to flush the shadow memory from third-party ↵Dmitry Vyukov2017-01-073-0/+7
| | | | | | | | | | | | libraries As discussed with Dmitry (https://goo.gl/SA4izd), I would like to introduce a function to be called from a third-party library to flush the shadow memory. In particular, we ran some experiments with our tool Archer (an OpenMP data race detector based on Tsan, https://github.com/PRUNER/archer) and flushing the memory at the end of an outer parallel region, slightly increase the runtime overhead, but reduce the memory overhead of about 30%. This feature would come very handy in case of very large OpenMP applications that may cause an "out of memory" exception when checked with Tsan. Reviewed in: https://reviews.llvm.org/D28443 Author: Simone Atzeni (simoatze) llvm-svn: 291346
* Revert "Enable weak hooks on darwin"Francis Ricci2017-01-071-5/+0
| | | | | | | | Reverts accidental upload. This reverts commit 421408c0f2cc811bcf9a945be6e95e46f76cb358. llvm-svn: 291316
* Enable weak hooks on darwinFrancis Ricci2017-01-071-0/+5
| | | | | | | | | | | | | | | | Summary: By default, darwin requires a definition for weak interface functions at link time. Adding the '-U' link flag with each weak function allows these weak interface functions to be used without definitions, which mirrors behavior on linux and windows. Reviewers: compnerd, eugenis Subscribers: kubabrecka, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D28203 llvm-svn: 291314
* [sanitizer] Add a 'print_module_map' flag which prints modules with UUIDs on ↵Kuba Mracek2017-01-062-0/+4
| | | | | | | | | | Darwin This patch add a new sanitizer flag, print_module_map, which enables printing a module map when the process exits, or after each report (for TSan). The output format is very similar to what Crash Reporter produces on Darwin (e.g. the format of module UUIDs). This enables users to use the existing symbol servers to offline symbolicate and aggregate reports. Differential Revision: https://reviews.llvm.org/D27400 llvm-svn: 291277
* [tsan] Fix string to bool conversion warnings in tsan testsVitaly Buka2016-12-271-3/+3
| | | | llvm-svn: 290568
* [tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query ↵Kuba Mracek2016-12-193-0/+89
| | | | | | | | | | 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 llvm-svn: 290119
* [tsan] Add interceptor for libcxx __shared_count::__release_shared()Kuba Mracek2016-12-151-3/+19
| | | | | | | | 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 llvm-svn: 289831
* tsan: allow Java VM iterate over allocated objectsDmitry Vyukov2016-12-142-0/+21
| | | | | | | | | | | | 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 llvm-svn: 289682
* Release memory to OS only when the requested range covers the entire pageEvgeniy Stepanov2016-11-304-6/+6
| | | | | | | | | | | | | | | | | Summary: The current code was sometimes attempting to release huge chunks of memory due to undesired RoundUp/RoundDown interaction when the requested range is fully contained within one memory page. Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27228 llvm-svn: 288271
* Return memory to OS right after free (not in the async thread).Evgeniy Stepanov2016-11-291-1/+3
| | | | | | | | | | | | | | | | | | Summary: In order to avoid starting a separate thread to return unused memory to the system (the thread interferes with process startup on Android, Zygota waits for all threads to exit before fork, but this thread never exits), try to return it right after free. Reviewers: eugenis Subscribers: cryptoad, filcab, danalbert, kubabrecka, llvm-commits Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27003 llvm-svn: 288091
* [tsan] Add support for GCD dispatch_suspend and dispatch_resumeKuba Mracek2016-11-241-0/+9
| | | | | | | | 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 llvm-svn: 287902
* tsan: mark cur_thread_placeholder definition as initial-execDmitry Vyukov2016-11-221-0/+1
| | | | | | | | | See https://sourceware.org/bugzilla/show_bug.cgi?id=20805 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78294 for context. Previously we marked only declaration as initial-exec. But compilers treat initial-exec attribute somewhat differently. Mark definition as well. llvm-svn: 287629
* [tsan] Call pthread interceptors directly in TSan RTL unit testsKuba Brecka2016-11-153-79/+114
| | | | | | | | On Darwin, we're running the TSan unit tests without interceptors. To make sure TSan observes all the pthread events (thread creating, thread join, condvar signal, etc.) in tsan_posix.cc, we should call the pthread interceptors directly, as we already do in tsan_test_util_posix.cc. This fixes some flaky failures on Darwin bots. Differential Revision: https://reviews.llvm.org/D26639 llvm-svn: 287026
* [tsan] Add support for C++ exceptions into TSan (call __tsan_func_exit ↵Kuba Brecka2016-11-141-0/+8
| | | | | | | | | | during unwinding), compiler-rt part This adds support for TSan C++ exception handling, where we need to add extra calls to __tsan_func_exit when a function is exitted via exception mechanisms. Otherwise the shadow stack gets corrupted (leaked). This patch moves and enhances the existing implementation of EscapeEnumerator that finds all possible function exit points, and adds extra EH cleanup blocks where needed. Differential Revision: https://reviews.llvm.org/D26177 llvm-svn: 286894
* [tsan] Expose __tsan_ignore_thread_begin and __tsan_ignore_thread_end in ↵Anna Zaks2016-11-112-0/+11
| | | | | | | | | | TSan interface This patch is needed to implement the function attribute that disable TSan checking at run time. Differential Revision: https://reviews.llvm.org/D25859 llvm-svn: 286658
* tsan: more precise handling of atomic storesDmitry Vyukov2016-11-081-1/+1
| | | | | | | | | Atomic stores terminate release sequences on the atomic variable, and must use ReleaseStore primitive instead of Release. This was broken in r192355 during a refactoring. Restore correct behavior and add a test. llvm-svn: 286211
* [tsan] Implement WriteMemoryProfile for DarwinKuba Brecka2016-10-312-7/+71
| | | | | | | | TSan’s memory usage profiling currently doesn’t work on Darwin. This patch implements measuring the amount of resident and dirty memory for each memory region. I also removed the GetShadowMemoryConsumption function, which seems to be unused. Differential Revision: https://reviews.llvm.org/D25973 llvm-svn: 285630
* [tsan] Add support for GCD target queuesKuba Brecka2016-10-311-18/+48
| | | | | | | | | | GCD (libdispatch) has a concept of “target queues”: Each queue has either an implicit or explicit target queue, where the task is handed over to when it’s time to execute it. For example, a concurrent queue can have a serial target queue (effectively making the first queue serial), or multiple queues can have the same serial target queue (which means tasks in all the queues are mutually excluded). Thus we need to acquire-release semantics on the full “chain” of target queues. This patch changes the way we Acquire() and Release() when executing tasks in queues. Now we’ll walk the chain of target queues and synchronize on each queue that is serial (or when dealing with a barrier block). This should avoid false positives when using dispatch_set_target_queue(). Differential Revision: https://reviews.llvm.org/D25835 llvm-svn: 285613
* tsan: add a hook to obtain number of reportsDmitry Vyukov2016-10-281-0/+5
| | | | | | | | Requested in: https://github.com/golang/go/issues/15972 Will help to fail individual test cases with races. llvm-svn: 285455
* tsan: round Go shadow to page boundaryDmitry Vyukov2016-10-281-1/+4
| | | | | | | | | | | | | There is a corner case reported in Go issue tracker: https://github.com/golang/go/issues/17065 On darwin data/bss segments may not be aligned to page bounary and mmap seems to be behaving differently than on linux (shrinks instead of enlarge unaligned regions). Explicitly round shadow to page bounary before mapping to avoid any such problems. llvm-svn: 285454
* tsan: always define SANITIZER_GODmitry Vyukov2016-10-2823-124/+115
| | | | | | | | | | | | | | | | | | | | | | Currently we either define SANITIZER_GO for Go or don't define it at all for C++. This works fine with preprocessor (ifdef/ifndef/defined), but does not work for C++ if statements (e.g. if (SANITIZER_GO) {...}). Also this is different from majority of SANITIZER_FOO macros which are always defined to either 0 or 1. Always define SANITIZER_GO to either 0 or 1. This allows to use SANITIZER_GO in expressions and in flag default values. Also remove kGoMode and kCppMode, which were meant to be used in expressions, but they are not defined in sanitizer_common code, so SANITIZER_GO become prevalent. Also convert some preprocessor checks to C++ if's or ternary expressions. Majority of this change is done mechanically with: sed "s#ifdef SANITIZER_GO#if SANITIZER_GO#g" sed "s#ifndef SANITIZER_GO#if \!SANITIZER_GO#g" sed "s#defined(SANITIZER_GO)#SANITIZER_GO#g" llvm-svn: 285443
* tsan: fix windows meta mappingDmitry Vyukov2016-10-281-0/+5
| | | | | | | | | Currently windows fails on startup with: CHECK failed: gotsan.cc:3077 "(((m - prev_m) / kMetaShadowSize)) == (((p - prev) / kMetaShadowCell))" (0x3ffffffeffffff7e, 0x6ffffff7e) Make MemToMeta do the same MemToShadow does on windows: add offset instead of or'ing it. llvm-svn: 285420
* tsan: fix code formattingDmitry Vyukov2016-10-281-1/+1
| | | | llvm-svn: 285418
* [sanitizers] Set Darwin specific linker and compiler flags for all testsAnna Zaks2016-10-261-1/+5
| | | | | | | | | | | | | | | | Looks like we are missing these flags only in tsan and sanitizer-common. This results in linker warnings in some settings as it can cause the Unit tests to be built with a different SDK version than that was used to build the runtime. For example, we are not setting the minimal deployment target on the tests but are setting the minimal deployment target for the sanitizer library, which leads to the following warning on some bots: ld: warning: object file (sanitizer_posix_test.cc.i386.o) was built for newer OSX version (10.12) than being linked (10.11). Differential Revision: https://reviews.llvm.org/D25860 https://reviews.llvm.org/D25352 llvm-svn: 285255
* Don't use internal symbolizer if we are in process of reporting Out-of-Memory.Vitaly Buka2016-09-291-2/+2
| | | | | | Reviewed by eugenis offline, as reviews.llvm.org is down. llvm-svn: 282805
* tsan: relaxed check in CheckShadowMappingDmitry Vyukov2016-09-261-2/+1
| | | | | | | | | | | | Some platforms use strange addresses in shadow mapping. E.g. aarch64/42vma: static const uptr kHiAppMemEnd = 0x3ffffffffffull; instead of 0x40000000000ull (the range is half-open). This caused bot failures after r282405: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/12242/steps/ninja%20check%201/logs/FAIL%3A%20SanitizerCommon-tsan-aarch64-Linux%3A%3Aclock_gettime.c Relaxed the new check in CheckShadowMapping to not expect round addresses. llvm-svn: 282407
* tsan: make shadow mapping linear within a single user regionDmitry Vyukov2016-09-262-19/+31
| | | | | | | | | | | | | | | | | | | This is a follow up to r282152. A more extensive testing on real apps revealed a subtle bug in r282152. The revision made shadow mapping non-linear even within a single user region. But there are lots of code in runtime that processes memory ranges and assumes that mapping is linear. For example, region memory access handling simply increments shadow address to advance to the next shadow cell group. Similarly, DontNeedShadowFor, java memory mover, search of heap memory block header, etc make similar assumptions. To trigger the bug user range would need to cross 0x008000000000 boundary. This was observed for a module data section. Make shadow mapping linear within a single user range again. Add a startup CHECK for linearity. llvm-svn: 282405
* tsan: remove kMidShadowOff mapping parameterDmitry Vyukov2016-09-261-6/+2
| | | | | | | kMidShadowOff is trivially computable from other parameters. Remove it. llvm-svn: 282404
* tsan: simplify meta mappingDmitry Vyukov2016-09-261-3/+2
| | | | | | | | | | | Don't xor user address with kAppMemXor in meta mapping. The only purpose of kAppMemXor is to raise shadow for ~0 user addresses, so that they don't map to ~0 (which would cause overlap between user memory and shadow). For meta mapping we explicitly add kMetaShadowBeg offset, so we don't need to additionally raise meta shadow. llvm-svn: 282403
OpenPOWER on IntegriCloud