summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl/tsan_sync.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/tsan/rtl to .cppNico Weber2019-08-011-296/+0
| | | | | | Like r367463, but for tsan/rtl. llvm-svn: 367564
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* sanitizers: consistently check result of MmapFixedNoReserveDmitry Vyukov2018-07-201-1/+2
| | | | | | | | | | | | | | | | MmapFixedNoReserve does not terminate process on failure. Failure to check its result and die will always lead to harder to debug crashes later in execution. This was observed in Go processes due to some address space conflicts. Consistently check result of MmapFixedNoReserve. While we are here also add warn_unused_result attribute to prevent such bugs in future and change return type to bool as that's what all callers want. Reviewed in https://reviews.llvm.org/D49367 llvm-svn: 337531
* tsan: give debug names to dense allocatorsDmitry Vyukov2017-07-121-1/+3
| | | | | | | Improves crash message on dense alloc overflow. Allows to understand what alloc overflowed. llvm-svn: 307780
* tsan: add new mutex annotationsDmitry Vyukov2017-03-261-4/+1
| | | | | | | | | | | | | | 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
* [tsan] Provide API for libraries for race detection on custom objectsKuba Mracek2017-02-021-0/+1
| | | | | | | | 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: always define SANITIZER_GODmitry Vyukov2016-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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: don't create sync objects on acquireDmitry Vyukov2016-06-271-2/+2
| | | | | | | Creating sync objects on acquire is pointless: acquire of a just created sync object if a no-op. llvm-svn: 273862
* tsan: fix another crash due to processorsDmitry Vyukov2016-05-101-5/+8
| | | | | | | | | | | | | | | | | | 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 windows Go supportDmitry Vyukov2016-04-271-0/+6
| | | | | | Unmap can't unmap arbitrary regions on windows. llvm-svn: 267716
* tsan: change tsan/Go interface for obtaining the current ProcessorDmitry Vyukov2016-04-271-4/+4
| | | | | | | | | | | | | | | Current interface assumes that Go calls ProcWire/ProcUnwire to establish the association between thread and proc. With the wisdom of hindsight, this interface does not work very well. I had to sprinkle Go scheduler with wire/unwire calls, and any mistake leads to hard to debug crashes. This is not something one wants to maintian. Fortunately, there is a simpler solution. We can ask Go runtime as to what is the current Processor, and that question is very easy to answer on Go side. Switch to such interface. llvm-svn: 267703
* tsan: split thread into logical and physical stateDmitry Vyukov2016-04-271-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | This is reincarnation of http://reviews.llvm.org/D17648 with the bug fix pointed out by Adhemerval (zatrazz). Currently ThreadState holds both logical state (required for race-detection algorithm, user-visible) and physical state (various caches, most notably malloc cache). Move physical state in a new Process entity. Besides just being the right thing from abstraction point of view, this solves several problems: Cache everything on P level in Go. Currently we cache on a mix of goroutine and OS thread levels. This unnecessary increases memory consumption. Properly handle free operations in Go. Frees are issue by GC which don't have goroutine context. As the result we could not do anything more than just clearing shadow. For example, we leaked sync objects and heap block descriptors. This will allow to get rid of libc malloc in Go (now we have Processor context for internal allocator cache). This in turn will allow to get rid of dependency on libc entirely. Potentially we can make Processor per-CPU in C++ mode instead of per-thread, which will reduce resource consumption. The distinction between Thread and Processor is currently used only by Go, C++ creates Processor per OS thread, which is equivalent to the current scheme. llvm-svn: 267678
* tsan: revert r262037Dmitry Vyukov2016-02-261-23/+23
| | | | | | Broke aarch64 and darwin bots. llvm-svn: 262046
* tsan: split thread into logical and physical stateDmitry Vyukov2016-02-261-23/+23
| | | | | | | | | | | | | | | | | | | | Currently ThreadState holds both logical state (required for race-detection algorithm, user-visible) and physical state (various caches, most notably malloc cache). Move physical state in a new Process entity. Besides just being the right thing from abstraction point of view, this solves several problems: 1. Cache everything on P level in Go. Currently we cache on a mix of goroutine and OS thread levels. This unnecessary increases memory consumption. 2. Properly handle free operations in Go. Frees are issue by GC which don't have goroutine context. As the result we could not do anything more than just clearing shadow. For example, we leaked sync objects and heap block descriptors. 3. This will allow to get rid of libc malloc in Go (now we have Processor context for internal allocator cache). This in turn will allow to get rid of dependency on libc entirely. 4. Potentially we can make Processor per-CPU in C++ mode instead of per-thread, which will reduce resource consumption. The distinction between Thread and Processor is currently used only by Go, C++ creates Processor per OS thread, which is equivalent to the current scheme. llvm-svn: 262037
* tsan: don't write to meta shadow unnecessarilyDmitry Vyukov2015-03-271-4/+6
| | | | | | | If user does malloc(1<<30), the write to meta shadow can cause excessive memory consumption. llvm-svn: 233373
* tsan: fix a bug in MetaMap::ResetRangeDmitry Vyukov2015-03-121-2/+4
| | | | | | | The bug was uncovered by NegativeTests.MmapTest from data-race-test suite, so port it as well. llvm-svn: 232032
* tsan: fix crash during __tsan_java_moveDmitry Vyukov2015-03-121-1/+59
| | | | | | | | Munmap interceptor did not reset meta shadow for the range, and __tsan_java_move crashed because it encountered non-zero meta shadow for the destination. llvm-svn: 232029
* [TSan] Use common flags in the same way as all the other sanitizersAlexey Samsonov2014-09-101-1/+1
| | | | llvm-svn: 217559
* tsan: allocate vector clocks using slab allocatorDmitry Vyukov2014-08-051-6/+11
| | | | | | | | | | Vector clocks is the most actively allocated object in tsan runtime. Current internal allocator is not scalable enough to handle allocation of clocks in scalable way (too small caches). This changes transforms clocks to 2-level array with 512-byte blocks. Since all blocks are of the same size, it's possible to cache them more efficiently in per-thread caches. llvm-svn: 214912
* tsan: reapply 212531 and 212532 with a fixDmitry Vyukov2014-07-081-4/+5
| | | | | | don't reset s->addr as well llvm-svn: 212565
* [TSan] Revert r212531 and r212532.Alexey Samsonov2014-07-081-4/+3
| | | | | | They cause "check-tsan" command to hang. Details in r212532 review thread. llvm-svn: 212562
* tsan: allow memory overlap in __tsan_java_moveDmitry Vyukov2014-07-081-3/+12
| | | | | | JVM actually moves memory between overlapping ranges. llvm-svn: 212560
* tsan: fix a potential hangDmitry Vyukov2014-07-081-2/+4
| | | | | | | idx0 is not updated in the branch, so if we take that branch idx0 will stay updated forever llvm-svn: 212532
* tsan: fix a bug in metamapDmitry Vyukov2014-07-081-1/+0
| | | | | | | | | The bug happens in the following case: Mutex is located at heap block beginning, when we call MutexDestroy, s->next is set to 0, so free can't find the MBlock related to the block. llvm-svn: 212531
* tsan: fix code formattingDmitry Vyukov2014-06-211-1/+1
| | | | llvm-svn: 211429
* tsan: refactor storage of meta information for heap blocks and sync objectsDmitry Vyukov2014-05-291-254/+153
| | | | | | | | | | | | | | | The new storage (MetaMap) is based on direct shadow (instead of a hashmap + per-block lists). This solves a number of problems: - eliminates quadratic behaviour in SyncTab::GetAndLock (https://code.google.com/p/thread-sanitizer/issues/detail?id=26) - eliminates contention in SyncTab - eliminates contention in internal allocator during allocation of sync objects - removes a bunch of ad-hoc code in java interface - reduces java shadow from 2x to 1/2x - allows to memorize heap block meta info for Java and Go - allows to cleanup sync object meta info for Go - which in turn enabled deadlock detector for Go llvm-svn: 209810
* tsan: use stack depot for goroutine creation stacks (as C++ threads do)Dmitry Vyukov2014-03-201-3/+4
| | | | llvm-svn: 204326
* tsan: implement new version of standalong deadlock detectorDmitry Vyukov2014-03-051-2/+3
| | | | | | | intercept pthread_cond (it is required to properly track state of mutexes) detect cycles in mutex graph llvm-svn: 202975
* tsan: refactor deadlock detectorDmitry Vyukov2014-02-281-1/+3
| | | | | | | | Introduce DDetector interface between the tool and the DD itself. It will help to experiment with other DD implementation, as well as reuse DD in other tools. llvm-svn: 202485
* [tsan] rudimentary support for deadlock detector in tsan (nothing really ↵Kostya Serebryany2014-02-141-0/+1
| | | | | | works yet except for a single tiny test). Also rename tsan's DeadlockDetector to InternalDeadlockDetector llvm-svn: 201407
* tsan: move shadow stack from thread descriptors to fixed addressesDmitry Vyukov2013-10-161-0/+5
| | | | | | | | This allows to increase max shadow stack size to 64K, and reliably catch shadow stack overflows instead of silently corrupting memory. llvm-svn: 192797
* tsan: fix crash when data race happens on out-of-bounds accesses.Dmitry Vyukov2013-04-241-0/+2
| | | | llvm-svn: 180180
* tsan: smaller memory block headers (32b->16b)Dmitry Vyukov2013-03-181-17/+25
| | | | llvm-svn: 177312
* tsan: use StackDepot in sync object to store creation stacksDmitry Vyukov2013-03-181-21/+1
| | | | llvm-svn: 177258
* tsan: java interface implementation skeletonDmitry Vyukov2012-12-201-12/+24
| | | | llvm-svn: 170707
* tsan: intercept fork() to prevent false race reports on fd'sDmitry Vyukov2012-12-181-0/+3
| | | | llvm-svn: 170433
* tsan: add mutexsets to reportsDmitry Vyukov2012-12-061-4/+20
| | | | | | With this change reports say what mutexes the threads hold around the racy memory accesses. llvm-svn: 169493
* tsan: increase max shadow stack size + reduce memory consumption at the same ↵Dmitry Vyukov2012-09-061-2/+6
| | | | | | time (by not memorizing full stacks in traces) llvm-svn: 163322
* tsan: proper handling of linker initialized mutexesDmitry Vyukov2012-08-181-0/+4
| | | | llvm-svn: 162169
* tsan: better diagnostics for destroy of a locked mutex + a testDmitry Vyukov2012-08-161-0/+1
| | | | llvm-svn: 162022
* tsan: support for linker initializer mutexes with static storage durationDmitry Vyukov2012-08-161-1/+2
| | | | llvm-svn: 162021
* tsan: store sync objects in memory block headers + delete them when the ↵Dmitry Vyukov2012-08-151-0/+51
| | | | | | block is freed llvm-svn: 161959
* tasn: do not remember stack traces for sync objects for Go (they are not ↵Dmitry Vyukov2012-07-271-0/+2
| | | | | | reported anyway) llvm-svn: 160861
* tsan: use dynamic shadow stack for GoDmitry Vyukov2012-07-161-1/+1
| | | | llvm-svn: 160288
* tsan: do not call malloc/free in memory access handling routine.Dmitry Vyukov2012-06-221-6/+26
| | | | | | This improves signal-/fork-safety of instrumented programs. llvm-svn: 158988
* [Sanitizer] Use DEFINE_REAL macro in TSan runtime to call libc ↵Alexey Samsonov2012-06-151-1/+1
| | | | | | implementations of functions. Move strchr to sanitizer_libc. llvm-svn: 158517
* [TSan] use efficient real_memcpy inside runtimeAlexey Samsonov2012-06-091-1/+1
| | | | llvm-svn: 158260
* [Sanitizer] move placement_new definiton from TSan to common runtimeAlexey Samsonov2012-06-071-1/+1
| | | | llvm-svn: 158145
* Remove file-type tags in .cc files in tsan/ and sanitizer_common/Alexey Samsonov2012-06-041-1/+1
| | | | llvm-svn: 157928
* tsan: simple memory profilerDmitry Vyukov2012-05-221-0/+20
| | | | llvm-svn: 157248
OpenPOWER on IntegriCloud