summaryrefslogtreecommitdiff
path: root/lib/tsan/rtl/tsan_defs.h
AgeCommit message (Collapse)Author
2016-04-27tsan: split thread into logical and physical stateDmitry Vyukov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267678 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-26tsan: revert r262037Dmitry Vyukov
Broke aarch64 and darwin bots. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262046 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-26tsan: split thread into logical and physical stateDmitry Vyukov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262037 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19Fix another -Wexpansion-to-defined warning in compiler-rt.Nico Weber
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258202 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30[tsan] Fix weakly imported functions on OS XKuba Brecka
On OS X, for weak function (that user can override by providing their own implementation in the main binary), we need extern `"C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE`. Fixes a broken test case on OS X, java_symbolization.cc, which uses a weak function __tsan_symbolize_external. Differential Revision: http://reviews.llvm.org/D14907 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254298 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04[tsan] Handle libdispatch worker threads on OS XKuba Brecka
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28Allow UBSan+MSan and UBSan+TSan combinations (Clang part).Alexey Samsonov
Embed UBSan runtime into TSan and MSan runtimes in the same as we do in ASan. Extend UBSan test suite to also run tests for these combinations. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@235954 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-17[TSan] Provide default values for compile definitions.Alexey Samsonov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229581 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13tsan: reduce size of vector clock in Go modeDmitry Vyukov
Go does not have freed memory. Reduces per-goroutine overhead from 455K to 356K. https://code.google.com/p/thread-sanitizer/issues/detail?id=89 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229113 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13tsan: remove stats from ThreadState ifndef TSAN_COLLECT_STATSDmitry Vyukov
Issue 89: Uses a lot of memory for each goroutine https://code.google.com/p/thread-sanitizer/issues/detail?id=89 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229112 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19tsan: remove TSAN_SHADOW_COUNTDmitry Vyukov
TSAN_SHADOW_COUNT is defined to 4 in all environments. Other values of TSAN_SHADOW_COUNT were never tested and were broken by recent changes to shadow mapping. Remove it as there is no reason to fix nor maintain it. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226466 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-03Remove TSAN_DEBUG in favor of SANITIZER_DEBUG.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225111 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09[tsan] remove TSAN_GO in favor of SANITIZER_GOKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223732 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[TSan] Use StackTrace from sanitizer_common where applicableAlexey Samsonov
Summary: This change removes `__tsan::StackTrace` class. There are now three alternatives: # Lightweight `__sanitizer::StackTrace`, which doesn't own a buffer of PCs. It is used in functions that need stack traces in read-only mode, and helps to prevent unnecessary allocations/copies (e.g. for StackTraces fetched from StackDepot). # `__sanitizer::BufferedStackTrace`, which stores buffer of PCs in a constant array. It is used in TraceHeader (non-Go version) # `__tsan::VarSizeStackTrace`, which owns buffer of PCs, dynamically allocated via TSan internal allocator. Test Plan: compiler-rt test suite Reviewers: dvyukov, kcc Reviewed By: kcc Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D6004 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221194 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-30tsan: optimize memory access functionsDmitry Vyukov
The optimization is two-fold: First, the algorithm now uses SSE instructions to handle all 4 shadow slots at once. This makes processing faster. Second, if shadow contains the same access, we do not store the event into trace. This increases effective trace size, that is, tsan can remember up to 10x more previous memory accesses. Perofrmance impact: Before: [ OK ] DISABLED_BENCH.Mop8Read (2461 ms) [ OK ] DISABLED_BENCH.Mop8Write (1836 ms) After: [ OK ] DISABLED_BENCH.Mop8Read (1204 ms) [ OK ] DISABLED_BENCH.Mop8Write (976 ms) But this measures only fast-path. On large real applications the speedup is ~20%. Trace size impact: On app1: Memory accesses : 1163265870 Including same : 791312905 (68%) on app2: Memory accesses : 166875345 Including same : 150449689 (90%) 90% of filtered events means that trace size is effectively 10x larger. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209897 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29tsan: refactor storage of meta information for heap blocks and sync objectsDmitry Vyukov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209810 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15tsan: allow to disable history collectionDmitry Vyukov
The mode is enabled with -DTSAN_NO_HISTORY=1 flag. Intended mostly for research purposes (how fast can it go w/o history). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208878 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-11tsan: fix vector clocksDmitry Vyukov
the new optimizations break when thread ids gets reused (clocks go backwards) add the necessary tests as well git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206035 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27tsan: better diagnostics if thread finishes with ignores enabledDmitry Vyukov
print thread creation stack and stacks where ignores were enabled. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195836 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16tsan: move shadow stack from thread descriptors to fixed addressesDmitry Vyukov
This allows to increase max shadow stack size to 64K, and reliably catch shadow stack overflows instead of silently corrupting memory. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192797 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-26[tsan] Move some suppressions-related code to common.Sergey Matveev
Factor out code to be reused in LSan. Also switch from linked list to vector. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184957 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-27tsan: print matched suppressions if print_suppressions=1 flag is providedDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178159 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-15[TSan] Switch TSan runtime to use ThreadRegistry class from sanitizer_commonAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177154 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01tsan: detect races between plain and atomic memory accessesDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174163 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30tsan: fix CPP_WEAK definition (it must be the other way around)Dmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@173932 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30tsan: introduce a helped macro CPP_WEAK (Go linker does not support weak ↵Dmitry Vyukov
symbols) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@173917 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06tsan: add mutexsets to reportsDmitry Vyukov
With this change reports say what mutexes the threads hold around the racy memory accesses. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169493 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04tsan: fix trace handling when trace is reused between threadsDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169259 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-28tsan: address several review commentsDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168789 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15tsan: switch to 4 shadow cells by default (since that's what we use ↵Dmitry Vyukov
everywhere now) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168059 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-08tsan: use GORACE env for options for GoDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167575 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-06tsan: lazily allocate shadow for GoDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167464 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-06tsan: fix constant typesDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167453 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-06tsan: fix code styleDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163326 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-06tsan: increase max shadow stack size + reduce memory consumption at the same ↵Dmitry Vyukov
time (by not memorizing full stacks in traces) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163322 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-15tsan: switch to new allocatorDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161953 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16tsan: use dynamic shadow stack for GoDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@160288 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-05tsan: Go language supportDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159754 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-29tsan/asan: unify atomics (move atomics from tsan to sanitizer_common)Dmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159437 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-29tsan: remove own memset/memcpy/memcmp (too messy)Dmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159430 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-27tsan: prevent insertion of unwanted memset/memcpy/memcmp into runtimeDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159294 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-22tsan: do not call malloc/free in memory access handling routine.Dmitry Vyukov
This improves signal-/fork-safety of instrumented programs. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158988 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15[Sanitizer] Use DEFINE_REAL macro in TSan runtime to call libc ↵Alexey Samsonov
implementations of functions. Move strchr to sanitizer_libc. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158517 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-14[Sanitizer] Move internal_memcmp to common sanitizer libcAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158450 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-09[TSan] use efficient real_memcpy inside runtimeAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158260 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08[Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158202 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08[TSan] s/internal_memset/real_memsetAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158200 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-07[Sanitizer] move internal_strdup and internal_memcpy to common runtime. Make ↵Alexey Samsonov
internal allocations from TSan runtime call InternalAlloc from common runtime git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158148 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[Sanitizer] Use common CHECK machinery. Currently each tool has to define ↵Alexey Samsonov
its own CheckFailed function. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158075 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[Sanitizer] Move more functions/constants to sanitizer_common.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158056 91177308-0d34-0410-b5e6-96231b3b80d8