summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/tsan/rtl to .cppNico Weber2019-08-011-444/+0
| | | | | | Like r367463, but for tsan/rtl. llvm-svn: 367564
* [TSan] Support fiber API on macOSJulian Lettner2019-04-201-1/+1
| | | | | | | | | | | | | | Committing on behalf of Yuri Per (yuri). Reviewers: dvyukov, kubamracek, yln Reviewed By: kubamracek Authored By: yuri Differential Revision: https://reviews.llvm.org/D58110 llvm-svn: 358802
* Dmitry Vyukov2019-02-131-1/+38
| | | | | | | | | | | | | | | | | | | | | | | tsan: add fiber support This patch adds functions for managing fibers: __tsan_get_current_fiber() __tsan_create_fiber() __tsan_destroy_fiber() __tsan_switch_to_fiber() __tsan_set_fiber_name() See the added tests for use examples. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D54889 [The previous commit of this change was reverted, this is a resubmit with a squashed fix for check_analyze.sh and COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED] llvm-svn: 353947
* Revert "tsan: add fiber support"Diana Picus2019-02-131-38/+1
| | | | | | | This reverts commit r353817 because we think it broke AARch64 and PowerPC buildbots. llvm-svn: 353939
* tsan: add fiber supportDmitry Vyukov2019-02-121-1/+38
| | | | | | | | | | | | | | | | | This patch adds functions for managing fibers: __tsan_get_current_fiber() __tsan_create_fiber() __tsan_destroy_fiber() __tsan_switch_to_fiber() __tsan_set_fiber_name() See the added tests for use examples. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D54889 llvm-svn: 353817
* sanitizers: Introduce ThreadType enumDmitry Vyukov2019-02-071-2/+3
| | | | | | | | | | | | | Replace bool workerthread flag with ThreadType enum. This change is preparation for fiber support. [dvyukov: fixed build of sanitizer_thread_registry_test.cc] Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57839 Context: https://reviews.llvm.org/D54889 llvm-svn: 353390
* 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
* tsan: add pthread_tryjoin_np and pthread_timedjoin_np interceptorsDmitry Vyukov2018-11-211-0/+6
| | | | | | | | | | Add pthread_tryjoin_np() and pthread_timedjoin_np() interceptors on Linux, so that ThreadSanitizer can handle programs using these functions. Author: Yuri Per (yuri) Reviewed in: https://reviews.llvm.org/D54521 llvm-svn: 347383
* Move __tsan::Vector to __sanitizerKamil Rytarowski2017-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | | Summary: The low-fat STL-like vector container will be reused in MSan. It is needed to implement an atexit(3) interceptor on NetBSD/amd64 in MSan. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc Reviewed By: dvyukov Subscribers: kubamracek, mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40726 llvm-svn: 319650
* tsan: prepare clock for future changesDmitry Vyukov2017-07-121-0/+4
| | | | | | | Pass ClockCache to ThreadClock::set and introduce ThreadCache::ResetCached. For now both are unused, but will reduce future diffs. llvm-svn: 307784
* [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-251-13/+1
| | | | | | | | | | 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] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek2017-04-171-1/+1
| | | | | | | | 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
* [tsan] Properly describe GCD worker threads in reportsKuba Mracek2017-02-021-2/+2
| | | | | | | | 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
* Release memory to OS only when the requested range covers the entire pageEvgeniy Stepanov2016-11-301-1/+2
| | | | | | | | | | | | | | | | | 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
* tsan: always define SANITIZER_GODmitry Vyukov2016-10-281-8/+8
| | | | | | | | | | | | | | | | | | | | | | 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
* [asan] first attempt at releasing free-d memory back to the system using ↵Kostya Serebryany2016-08-261-2/+2
| | | | | | madvise. Requires quite some tuning. llvm-svn: 279887
* tsan: fix leak of shadow stacksDmitry Vyukov2016-07-201-0/+6
| | | | llvm-svn: 276103
* 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
OpenPOWER on IntegriCloud