summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
Commit message (Collapse)AuthorAgeFilesLines
* tsan: change tsan/Go interface for obtaining the current ProcessorDmitry Vyukov2016-04-271-3/+3
| | | | | | | | | | | | | | | 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-17/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+17
| | | | | | Broke aarch64 and darwin bots. llvm-svn: 262046
* tsan: split thread into logical and physical stateDmitry Vyukov2016-02-261-17/+5
| | | | | | | | | | | | | | | | | | | | 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] Handle libdispatch worker threads on OS XKuba Brecka2015-11-041-2/+6
| | | | | | | | On OS X, GCD worker threads are created without a call to pthread_create. We need to properly register these threads with ThreadCreate and ThreadStart. This patch uses a libpthread API (`pthread_introspection_hook_install`) to get notifications about new threads and about threads that are about to be destroyed. Differential Revision: http://reviews.llvm.org/D14328 llvm-svn: 252049
* Revert "Apply modernize-use-default to compiler-rt."Alexey Samsonov2015-10-301-1/+2
| | | | | | | | | | | | This reverts commit r250823. Replacing at least some of empty constructors with "= default" variants is a semantical change which we don't want. E.g. __tsan::ClockBlock contains a union of large arrays, and it's critical for correctness and performance that we don't memset() these arrays in the constructor. llvm-svn: 251717
* Apply modernize-use-default to compiler-rt.Angel Garcia Gomez2015-10-201-2/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: klimek, bkramer Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13892 llvm-svn: 250823
* [Tsan] Do not sanitize memcpy() during thread initialization on FreeBSDViktor Kutuzov2015-03-161-0/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D8324 llvm-svn: 232381
* [TSan] Provide default values for compile definitions.Alexey Samsonov2015-02-171-1/+1
| | | | | | | | | Provide defaults for TSAN_COLLECT_STATS and TSAN_NO_HISTORY. Replace #ifdef directives with #if. This fixes a bug introduced in r229112, where building TSan runtime with -DTSAN_COLLECT_STATS=0 would still enable stats collection and reporting. llvm-svn: 229581
* tsan: remove everything related to rss/background thread in Go modeDmitry Vyukov2015-02-161-0/+2
| | | | | | | | | In Go mode the background thread is not started (internal_thread_start is empty). There is no sense in having this code compiled in. Also removes dependency on sanitizer_linux_libcdep.cc which is good, ideally Go runtime does not depend on libc at all. llvm-svn: 229396
* tsan: remove stats from ThreadState ifndef TSAN_COLLECT_STATSDmitry Vyukov2015-02-131-0/+2
| | | | | | | Issue 89: Uses a lot of memory for each goroutine https://code.google.com/p/thread-sanitizer/issues/detail?id=89 llvm-svn: 229112
* Remove TSAN_DEBUG in favor of SANITIZER_DEBUG.Alexey Samsonov2015-01-031-1/+1
| | | | llvm-svn: 225111
* tsan: fix trace initialization during thread id reuseDmitry Vyukov2014-12-251-7/+5
| | | | | | | | | The current code leaves the first event in the trace part uninitialized (from the previous thread). It can cause unpredictable behavior during stack/mutexset restoration. Initialize the first event to a fake harmless memory access. llvm-svn: 224834
* tsan: reset stack0 in the first partition of thread traceDmitry Vyukov2014-12-221-1/+4
| | | | | | | stack0/mset0 contained bogus values from the previous thread that used the same id llvm-svn: 224702
* [tsan] remove TSAN_GO in favor of SANITIZER_GOKostya Serebryany2014-12-091-8/+8
| | | | llvm-svn: 223732
* [TSan] Use common flags in the same way as all the other sanitizersAlexey Samsonov2014-09-101-2/+2
| | | | llvm-svn: 217559
* tsan: handle early signalsDmitry Vyukov2014-09-031-2/+1
| | | | | | | The second part of the fix of https://code.google.com/p/thread-sanitizer/issues/detail?id=71 llvm-svn: 217031
* tsan: allocate vector clocks using slab allocatorDmitry Vyukov2014-08-051-5/+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: flush metamap per-thread cache when thread finishesDmitry Vyukov2014-06-061-0/+1
| | | | llvm-svn: 210347
* tsan: refactor storage of meta information for heap blocks and sync objectsDmitry Vyukov2014-05-291-1/+1
| | | | | | | | | | | | | | | 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: refactor suppressions machineryDmitry Vyukov2014-05-281-2/+2
| | | | | | | | | | The refactoring makes suppressions more flexible and allow to suppress based on arbitrary number of stacks. In particular it fixes: https://code.google.com/p/thread-sanitizer/issues/detail?id=64 "Make it possible to suppress deadlock reports by any stack (not just first)" llvm-svn: 209757
* tsan: allow to suppress all reportsDmitry Vyukov2014-04-251-1/+1
| | | | | | Fixes issue https://code.google.com/p/thread-sanitizer/issues/detail?id=45 llvm-svn: 207218
* tsan: fix vector clocksDmitry Vyukov2014-04-111-2/+2
| | | | | | | the new optimizations break when thread ids gets reused (clocks go backwards) add the necessary tests as well llvm-svn: 206035
* tsan: deobfuscate global ctx variableDmitry Vyukov2014-03-201-14/+5
| | | | llvm-svn: 204327
* tsan: use stack depot for goroutine creation stacks (as C++ threads do)Dmitry Vyukov2014-03-201-4/+0
| | | | llvm-svn: 204326
* tsan: refactor deadlock detectorDmitry Vyukov2014-02-281-2/+12
| | | | | | | | 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: do not deadlock on forkDmitry Vyukov2014-01-241-0/+10
| | | | | | | | | | | | | Currently correct programs can deadlock after fork, because atomic operations and async-signal-safe calls are not async-signal-safe under tsan. With this change: - if a single-threaded program forks, the child continues running with verification enabled (the tsan background thread is recreated as well) - if a multi-threaded program forks, then the child runs with verification disabled (memory accesses, atomic operations and interceptors are disabled); it's expected that it will exec soon anyway - if the child tries to create more threads after multi-threaded fork, the program aborts with error message - die_after_fork flag is added that allows to continue running, but all bets are off http://llvm-reviews.chandlerc.com/D2614 llvm-svn: 199993
* tsan: remove in_rtl counterDmitry Vyukov2013-12-241-9/+0
| | | | | | | | This is intended to address the following problem. Episodically we see CHECK-failures when recursive interceptors call back into user code. Effectively we are not "in_rtl" at this point, but it's very complicated and fragile to properly maintain in_rtl property. Instead get rid of it. It was used mostly for sanity CHECKs, which basically never uncover real problems. Instead introduce ignore_interceptors flag, which is used in very few narrow places to disable recursive interceptors (e.g. during runtime initialization). llvm-svn: 197979
* tsan: clarify "thread ended with ignores enabled" messageDmitry Vyukov2013-11-271-0/+2
| | | | llvm-svn: 195858
* tsan: better diagnostics if thread finishes with ignores enabledDmitry Vyukov2013-11-271-8/+29
| | | | | | | print thread creation stack and stacks where ignores were enabled. llvm-svn: 195836
* tsan: move shadow stack from thread descriptors to fixed addressesDmitry Vyukov2013-10-161-6/+9
| | | | | | | | 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: add annotations to ignore synchronization operationsDmitry Vyukov2013-10-101-12/+8
| | | | | | | | The annotations are AnnotateIgnoreSyncBegin/End, may be useful to ignore some infrastructure synchronization that introduces lots of false negatives. llvm-svn: 192355
* tsan: use memory access size for Go after allDmitry Vyukov2013-06-061-21/+0
| | | | | | helps to make range access functions correct and fast llvm-svn: 183418
* tsan: detect when a thread ends with ignores enabledDmitry Vyukov2013-05-211-0/+9
| | | | llvm-svn: 182354
* tsan: better reporting of thread leaksDmitry Vyukov2013-03-211-10/+28
| | | | | | | 1. do not report running threads as leaks 2. aggregate leaked threads by creation stack llvm-svn: 177647
* tsan: special handling of .rodata (don't try to find races, don't keep ↵Dmitry Vyukov2013-03-201-0/+7
| | | | | | shadow, dont' put into traces) llvm-svn: 177517
* tsan: move trace header into 0x600000000000 rangeDmitry Vyukov2013-03-201-13/+6
| | | | | | eliminat thread "dead info" altogether llvm-svn: 177512
* tsan: flush dead thread info earlier (when another thread is finished rather ↵Dmitry Vyukov2013-03-191-4/+3
| | | | | | than new thread is created) llvm-svn: 177394
* tsan: fix memory leakDmitry Vyukov2013-03-191-0/+1
| | | | llvm-svn: 177387
* tsan: touch less shadow memory during operations on big memory rangesDmitry Vyukov2013-03-181-3/+4
| | | | | | greatly reduces memory consumption llvm-svn: 177289
* tsan: mark shadow for thread stack as "don't need" when thread exitsDmitry Vyukov2013-03-181-12/+4
| | | | llvm-svn: 177288
* tsan: fix clang -Wall buildDmitry Vyukov2013-03-181-0/+5
| | | | | | | Clang does not like classes with virtual functions but w/o virtual dtor. Go does not like libstdc++ (operator delete). llvm-svn: 177267
* [TSan] re-apply r177249 lost in editsAlexey Samsonov2013-03-181-1/+2
| | | | llvm-svn: 177265
* tsan: fix memory leakDmitry Vyukov2013-03-181-0/+1
| | | | llvm-svn: 177262
* tsan: use StackDepot for thread creation stacksDmitry Vyukov2013-03-181-0/+4
| | | | llvm-svn: 177261
* tsan: fix Go buildDmitry Vyukov2013-03-181-14/+16
| | | | llvm-svn: 177260
* [TSan] fix undefined variable in debug TSan buildAlexey Samsonov2013-03-181-1/+2
| | | | llvm-svn: 177249
* [TSan] Switch TSan runtime to use ThreadRegistry class from sanitizer_commonAlexey Samsonov2013-03-151-223/+140
| | | | llvm-svn: 177154
* tsan: do not imitate memory write on malloc() (Go)Dmitry Vyukov2013-02-131-0/+22
| | | | | | better memory range access functions (put only 1 event to trace) (Go) llvm-svn: 175056
* tsan: detect races between plain and atomic memory accessesDmitry Vyukov2013-02-011-19/+3
| | | | llvm-svn: 174163
OpenPOWER on IntegriCloud