summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_thread_registry.cc
AgeCommit message (Collapse)Author
2017-11-26Prevent Thread Exited/Joined events raceKamil Rytarowski
Summary: Add atomic verification to ensure that Thread is Joined after marking it Finished. It is required for NetBSD in order to prevent Thread Exited/Joined race, that may occur when native system libpthread(3) cannot be reliably traced in a way to guarantee that the mentioned events happen one after another. This change fixes at least TSan and LSan on NetBSD. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, vitalybuka Reviewed By: dvyukov Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40294 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319004 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09[asan] Refactor thread creation bookkeepingVitaly Buka
Summary: This is a pure refactoring change. It paves the way for OS-specific implementations, such as Fuchsia's, that can do most of the per-thread bookkeeping work in the creator thread before the new thread actually starts. This model is simpler and cleaner, avoiding some race issues that the interceptor code for thread creation has to do for the existing OS-specific implementations. Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: alekseyshl Subscribers: phosek, filcab, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36385 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310432 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09[asan] Complete the Fuchsia portVitaly Buka
Submitted on behalf of Roland McGrath. Reviewers: kcc, eugenis, alekseyshl, vitalybuka Reviewed By: vitalybuka Subscribers: filcab, vitalybuka, srhines, kubamracek, mgorny, phosek, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35865 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17[sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300473 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02[tsan] Properly describe GCD worker threads in reportsKuba Mracek
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293882 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28tsan: always define SANITIZER_GODmitry Vyukov
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" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@285443 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-02[sanitizer] Don't reuse the main thread in ThreadRegistryKuba Brecka
There is a hard-to-reproduce crash happening on OS X that involves terminating the main thread (dispatch_main does that, see discussion at http://reviews.llvm.org/D18496) and later reusing the main thread's ThreadContext. This patch disables reuse of the main thread. I believe this problem exists only on OS X, because on other systems the main thread cannot be terminated without exiting the process. Differential Revision: http://reviews.llvm.org/D19722 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268238 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02tsan: address comments in r214912Dmitry Vyukov
See http://reviews.llvm.org/D4794 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216900 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-05tsan: allocate vector clocks using slab allocatorDmitry Vyukov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214912 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
2014-02-06tsan: improve error message for GoDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200914 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-29tsan/asan: support pthread_setname_np to set thread namesDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193602 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-29Fix MSVC warnings at the -W2 levelTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182848 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-27[sanitizer] Move FindThreadByOSIdLocked from lsan to sanitizer_common.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182728 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-25[Sanitizer] Compile sanitizer runtimes with -Wno-non-virtual-dtor. Virtual ↵Alexey Samsonov
dtors may be a problem for us, as sanitizer runtime should not generally assume libstdc++ presence. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177860 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19tsan: flush dead thread info earlier (when another thread is finished rather ↵Dmitry Vyukov
than new thread is created) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177394 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-18tsan: fix clang -Wall buildDmitry Vyukov
Clang does not like classes with virtual functions but w/o virtual dtor. Go does not like libstdc++ (operator delete). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177267 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-15Fix a virtual destructor warning.Eric Christopher
Patch by Manuel Klimek! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177132 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-14[Sanitizer] Fix compiler warnings and style issues in sanitizer_common ↵Alexey Samsonov
tests. Use -Werror=sign-compare when building them. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177077 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-14[Sanitizer] Add generic ThreadRegistry class for sanitizer runtimes. This ↵Alexey Samsonov
class holds basic thread bookkeeping logic and allows specific sanitizer runtimes to create thread contexts and mark threads as created/running/joined etc. The class is based on the way we currently store thread contexts in TSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177074 91177308-0d34-0410-b5e6-96231b3b80d8