summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl
Commit message (Collapse)AuthorAgeFilesLines
...
* tsan: refactor SyncClock codeDmitry Vyukov2017-07-122-55/+54
| | | | | | | | | 1. Add SyncClock::ResetImpl which removes code duplication between ctor and Reset. 2. Move SyncClock::Resize to SyncClock methods, currently it's defined between ThreadClock methods. llvm-svn: 307785
* tsan: prepare clock for future changesDmitry Vyukov2017-07-125-8/+18
| | | | | | | Pass ClockCache to ThreadClock::set and introduce ThreadCache::ResetCached. For now both are unused, but will reduce future diffs. llvm-svn: 307784
* tsan: s/-1/kInvalidTid/Dmitry Vyukov2017-07-121-1/+1
| | | | llvm-svn: 307781
* tsan: give debug names to dense allocatorsDmitry Vyukov2017-07-123-5/+13
| | | | | | | Improves crash message on dense alloc overflow. Allows to understand what alloc overflowed. llvm-svn: 307780
* tsan: don't create sync objects on acquire-loadDmitry Vyukov2017-07-121-5/+11
| | | | | | | Don't create sync object if it does not exist yet. For example, an atomic pointer is initialized to nullptr and then periodically acquire-loaded. llvm-svn: 307778
* Refactor MemoryMappingLayout::Next to use a single struct instead of output ↵Francis Ricci2017-07-112-19/+15
| | | | | | | | | | | | | | | | | | | | | | | | | parameters. NFC. Summary: This is the first in a series of patches to refactor sanitizer_procmaps to allow MachO section information to be exposed on darwin. In addition, grouping all segment information in a single struct is cleaner than passing it through a large set of output parameters, and avoids the need for annotations of NULL parameters for unneeded information. The filename string is optional and must be managed and supplied by the calling function. This is to allow the MemoryMappedSegment struct to be stored on the stack without causing overly large stack sizes. Reviewers: alekseyshl, kubamracek, glider Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D35135 llvm-svn: 307688
* Fix a build failure due to r307541 (tsan_rtl_aarch64.S:54: Error: unknown ↵Kuba Mracek2017-07-101-1/+1
| | | | | | pseudo-op: `.'). llvm-svn: 307549
* Fix-up for r307540.Kuba Mracek2017-07-101-2/+2
| | | | llvm-svn: 307547
* [tsan] Add comments for the bool argument of ↵Kuba Mracek2017-07-102-9/+9
| | | | | | | | ThreadIgnoreBegin/ThreadIgnoreSyncBegin, NFC. Differential Revision: https://reviews.llvm.org/D35134 llvm-svn: 307545
* [tsan] Add a mapping for Darwin/AArch64Kuba Mracek2017-07-102-9/+49
| | | | | | | | This patch defines the TSan memory map and offsets for Darwin on AArch64. Differential Revision: https://reviews.llvm.org/D35147 llvm-svn: 307544
* [tsan] Port setjmp/longjmp assembly to Darwin/AArch64Kuba Mracek2017-07-103-25/+116
| | | | | | | | This patch ports the assembly file implementing TSan's setjmp support to AArch64 on Darwin. Differential Revision: https://reviews.llvm.org/D35143 llvm-svn: 307541
* [tsan] Add a max VM address check for Darwin/AArch64Kuba Mracek2017-07-101-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D35154 llvm-svn: 307540
* [Sanitizers] Consolidate internal errno definitions.Alex Shlyapnikov2017-07-062-14/+6
| | | | | | | Move internal errno definitions to common to be shared by all sanitizers and to be used by allocators. llvm-svn: 307233
* MergeAlex Shlyapnikov2017-06-291-1/+1
| | | | llvm-svn: 306746
* [Sanitizers] Operator new() interceptors always die on allocation errorAlex Shlyapnikov2017-06-281-5/+8
| | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 306604
* [Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocatorAlex Shlyapnikov2017-06-201-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Move cached allocator_may_return_null flag to sanitizer_allocator.cc and provide API to consolidate and unify the behavior of all specific allocators. Make all sanitizers using CombinedAllocator to follow AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM happens. When OOM happens, turn allocator_out_of_memory flag on regardless of allocator_may_return_null flag value (it used to not to be set when allocator_may_return_null == true). release_to_os_interval_ms and rss_limit_exceeded will likely be moved to sanitizer_allocator.cc too (later). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34310 llvm-svn: 305858
* tsan: fix reading of mutex flagsDmitry Vyukov2017-06-131-1/+1
| | | | | | | SyncVar::IsFlagSet returns true if any flag is set. This is wrong. Check the actual requested flag. llvm-svn: 305281
* tsan: fix pedantic warningsDmitry Vyukov2017-06-131-3/+5
| | | | | | ISO C++ does not allow ?: with omitted middle operand llvm-svn: 305273
* [tsan]: Fix GNU version of strerror_r interceptorVitaly Buka2017-06-071-0/+1
| | | | | | | | | | 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 llvm-svn: 304858
* Don't require ThreadState to be contained within tls on all platformsFrancis Ricci2017-05-254-19/+51
| | | | | | | | | | The existing implementation ran CHECKs to assert that the thread state was stored inside the tls. However, the mac implementation of tsan doesn't store the thread state in tls, so these checks fail once darwin tls support is added to the sanitizers. Only run these checks on platforms where the thread state is expected to be contained in the tls. llvm-svn: 303886
* [sanitizer] Change SizeClassAllocator32 to accept just one templateKostya Kortchinsky2017-05-151-6/+12
| | | | | | | | | | | | | | | | | | | | | Summary: With rL279771, SizeClassAllocator64 was changed to accept only one template instead of 5, for the following reasons: "First, this will make the mangled names shorter. Second, this will make adding more parameters simpler". This patch mirrors that work for SizeClassAllocator32. This is in preparation for introducing the randomization of chunks in the 32-bit SizeClassAllocator in a later patch. Reviewers: kcc, alekseyshl, dvyukov Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D33141 llvm-svn: 303071
* [tsan] Detect races on modifying accesses in Swift codeKuba Mracek2017-05-037-30/+77
| | | | | | | | 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: allow fast large MemoryRangeSet on non-Windows GoDmitry Vyukov2017-05-021-3/+2
| | | | | | | | | | | | The fast reset for large memory regions is not working only on windows. So enable it for Go/linux/darwin/freebsd. See https://github.com/golang/go/issues/20139 for background and motivation. Based on idea by Josh Bleecher Snyder. llvm-svn: 301927
* [compiler-rt] move tsan's Android __get_tls() to sanitizer_commonKostya Kortchinsky2017-05-021-19/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: TSan's Android `__get_tls()` and `TLS_SLOT_TSAN` can be used by other sanitizers as well (see D32649), this change moves them to sanitizer_common. I picked sanitizer_linux.h as their new home. In the process, add the 32-bit versions for ARM, i386 & MIPS. Can the address of `__get_tls()[TLS_SLOT_TSAN]` change in between the calls? I am not sure if there is a need to repeat the construct as opposed to using a variable. So I left things as they were. Testing on my side was restricted to a successful cross-compilation. Reviewers: dvyukov, kubamracek Reviewed By: dvyukov Subscribers: aemerson, rengolin, srhines, dberris, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D32705 llvm-svn: 301926
* tsan: support linker init flag in __tsan_mutex_destroyDmitry Vyukov2017-05-013-4/+4
| | | | | | | | | | | | | | For a linker init mutex with lazy flag setup (no __tsan_mutex_create call), it is possible that no lock/unlock happened before the destroy call. Then when destroy runs we still don't know that it is a linker init mutex and will emulate a memory write. This in turn can lead to false positives as the mutex is in fact linker initialized. Support linker init flag in destroy annotation to resolve this. llvm-svn: 301795
* [tsan] Track external tags in thread tracesKuba Mracek2017-04-304-20/+61
| | | | | | | | To make the TSan external API work with Swift and other use cases, we need to track "tags" for individual memory accesses. Since there is no space to store this information in shadow cells, let's use the thread traces for that. This patch stores the tag as an extra frame in the stack traces (by calling FuncEntry and FuncExit with the address of a registered tag), this extra frame is then stripped before printing the backtrace to stderr. Differential Revision: https://reviews.llvm.org/D32382 llvm-svn: 301777
* [tsan] Remove the extra word "object" from description of external racesKuba Mracek2017-04-241-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D32383 llvm-svn: 301189
* [tsan] Refactor __tsan_external_read/__tsan_external_write to avoid code ↵Kuba Mracek2017-04-211-20/+16
| | | | | | | | | | duplication Let's introduce a ExternalAccess function that has the shared code only once. Differential Revision: https://reviews.llvm.org/D32360 llvm-svn: 301008
* [tsan] Track external API accesses as 1-byte accesses (instead of 8-byte)Kuba Mracek2017-04-211-2/+2
| | | | | | | | It doesn't really make sense to track them as 8-byte accesses. Differential Revision: https://reviews.llvm.org/D32359 llvm-svn: 301001
* [tsan] Ignore memory accesses for libignored modules for "external" racesKuba Mracek2017-04-213-7/+16
| | | | | | | | 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-213-1/+4
| | | | | | | | 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-175-7/+8
| | | | | | | | 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
* Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systemsFrancis Ricci2017-04-131-12/+2
| | | | | | | | | | | | | | | | | Summary: Lsan was using PTHREAD_CREATE_JOINABLE/PTHREAD_CREATE_DETACHED as truthy values, which works on Linux, where the values are 0 and 1, but this fails on OS X, where the values are 1 and 2. Set PTHREAD_CREATE_DETACHED to the correct value for a given system. Reviewers: kcc, glider, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31883 llvm-svn: 300221
* [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-2614-107/+318
| | | | | | | | | | | | | | 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-0210-12/+135
| | | | | | | | 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-028-10/+18
| | | | | | | | 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
* [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
* 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
OpenPOWER on IntegriCloud