summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* [sanitizer] Support libc++abi in addition to libstdc++Petr Hosek2017-07-261-1/+2
| | | | | | | | | | | This change adds sanitizer support for LLVM's libunwind and libc++abi as an alternative to libstdc++. This allows using the in tree version of libunwind and libc++abi which is useful when building a toolchain for different target. Differential Revision: https://reviews.llvm.org/D34501 llvm-svn: 309074
* [sanitizer] Support compiler-rt builtinsPetr Hosek2017-07-252-2/+8
| | | | | | | | | This change adds support for compiler-rt builtins as an alternative compiler runtime to libgcc. Differential Revision: https://reviews.llvm.org/D35165 llvm-svn: 309060
* [Sanitizers] TSan allocator set errno on failure.Alex Shlyapnikov2017-07-247-43/+170
| | | | | | | | | | | | | | | | | | Summary: Set proper errno code on allocation failures and change realloc, pvalloc, aligned_alloc, memalign and posix_memalign implementation to satisfy their man-specified requirements. Modify allocator API implementation to bring it closer to other sanitizers allocators. Reviewers: dvyukov Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D35690 llvm-svn: 308929
* [sanitizer_common] Move filesystem-related code out of sanitizer_common.ccVitaly Buka2017-07-223-0/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Submitted on behalf of Roland McGrath. Reviewers: kcc, eugenis, alekseyshl Reviewed By: alekseyshl Subscribers: vitalybuka, llvm-commits, kubamracek, mgorny, phosek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35591 llvm-svn: 308819
* Revert "[sanitizer_common] Move filesystem-related code out of ↵Vitaly Buka2017-07-203-3/+0
| | | | | | | | | | sanitizer_common.cc" Breaks Windows build. This reverts commit r308640. llvm-svn: 308648
* [sanitizer_common] Move filesystem-related code out of sanitizer_common.ccAlex Shlyapnikov2017-07-203-0/+3
| | | | | | | | | | | | | | | | | This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Commiting for mcgrathr. Reviewers: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35591 llvm-svn: 308640
* [Sanitizers] ASan/MSan/LSan allocators set errno on failure.Alex Shlyapnikov2017-07-181-0/+1
| | | | | | | | | | | | | | | | | | | | | Summary: ASan/MSan/LSan allocators set errno on allocation failures according to malloc/calloc/etc. expected behavior. MSan allocator was refactored a bit to make its structure more similar with other allocators. Also switch Scudo allocator to the internal errno definitions. TSan allocator changes will follow. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D35275 llvm-svn: 308344
* tsan: optimize sync clock memory consumptionDmitry Vyukov2017-07-144-197/+512
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change implements 2 optimizations of sync clocks that reduce memory consumption: Use previously unused first level block space to store clock elements. Currently a clock for 100 threads consumes 3 512-byte blocks: 2 64-bit second level blocks to store clock elements +1 32-bit first level block to store indices to second level blocks Only 8 bytes of the first level block are actually used. With this change such clock consumes only 2 blocks. Share similar clocks differing only by a single clock entry for the current thread. When a thread does several release operations on fresh sync objects without intervening acquire operations in between (e.g. initialization of several fields in ctor), the resulting clocks differ only by a single entry for the current thread. This change reuses a single clock for such release operations. The current thread time (which is different for different clocks) is stored in dirty entries. We are experiencing issues with a large program that eats all 64M clock blocks (32GB of non-flushable memory) and crashes with dense allocator overflow. Max number of threads in the program is ~170 which is currently quite unfortunate (consume 4 blocks per clock). Currently it crashes after consuming 60+ GB of memory. The first optimization brings clock block consumption down to ~40M and allows the program to work. The second optimization further reduces block consumption to "modest" 16M blocks (~8GB of RAM) and reduces overall RAM consumption to ~30GB. Measurements on another real world C++ RPC benchmark show RSS reduction from 3.491G to 3.186G and a modest speedup of ~5%. Go parallel client/server HTTP benchmark: https://github.com/golang/benchmarks/blob/master/http/http.go shows RSS reduction from 320MB to 240MB and a few percent speedup. Reviewed in https://reviews.llvm.org/D35323 llvm-svn: 308018
* Fix sanitizer build against latest glibcKostya Serebryany2017-07-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: libsanitizer doesn't build against latest glibc anymore, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066 for details. One of the changes is that stack_t changed from typedef struct sigaltstack { ... } stack_t; to typedef struct { ... } stack_t; for conformance reasons. And the other change is that the glibc internal __need_res_state macro is now ignored, so when doing ``` #define __need_res_state #include <resolv.h> ``` the effect is now the same as just ``` #include <resolv.h> ``` and thus one doesn't get just the ``` struct __res_state { ... }; ``` definition, but newly also the ``` extern struct __res_state *__res_state(void) __attribute__ ((__const__)); ``` prototype. So __res_state is no longer a type, but a function. Reviewers: kcc, ygribov Reviewed By: kcc Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D35246 llvm-svn: 307969
* On Darwin, start building the TSan dylib for the iOS simulator.Kuba Mracek2017-07-121-0/+7
| | | | llvm-svn: 307816
* tsan: remove some clock-related statsDmitry Vyukov2017-07-123-12/+4
| | | | | | | The stats are too dependent on implementation and won't be relevant in future. llvm-svn: 307786
* tsan: refactor SyncClock codeDmitry Vyukov2017-07-122-55/+54
| | | | | | | | | 1. Add SyncClock::ResetImpl which removes code duplication between ctor and Reset. 2. Move SyncClock::Resize to SyncClock methods, currently it's defined between ThreadClock methods. llvm-svn: 307785
* tsan: prepare clock for future changesDmitry Vyukov2017-07-126-23/+35
| | | | | | | Pass ClockCache to ThreadClock::set and introduce ThreadCache::ResetCached. For now both are unused, but will reduce future diffs. llvm-svn: 307784
* tsan: s/-1/kInvalidTid/Dmitry Vyukov2017-07-121-1/+1
| | | | llvm-svn: 307781
* tsan: give debug names to dense allocatorsDmitry Vyukov2017-07-123-5/+13
| | | | | | | Improves crash message on dense alloc overflow. Allows to understand what alloc overflowed. llvm-svn: 307780
* tsan: don't create sync objects on acquire-loadDmitry Vyukov2017-07-121-5/+11
| | | | | | | Don't create sync object if it does not exist yet. For example, an atomic pointer is initialized to nullptr and then periodically acquire-loaded. llvm-svn: 307778
* tsan: add another test for clock growthDmitry Vyukov2017-07-121-0/+36
| | | | llvm-svn: 307777
* [tsan] Update test to r307338Vitaly Buka2017-07-121-2/+2
| | | | | | | r307338 enabled new optimization reducing number of operation in tested functions. There is no any performance regression detectable with TsanRtlTest DISABLED_BENCH.Mop* tests. llvm-svn: 307739
* Refactor MemoryMappingLayout::Next to use a single struct instead of output ↵Francis Ricci2017-07-113-29/+24
| | | | | | | | | | | | | | | | | | | | | | | | | parameters. NFC. Summary: This is the first in a series of patches to refactor sanitizer_procmaps to allow MachO section information to be exposed on darwin. In addition, grouping all segment information in a single struct is cleaner than passing it through a large set of output parameters, and avoids the need for annotations of NULL parameters for unneeded information. The filename string is optional and must be managed and supplied by the calling function. This is to allow the MemoryMappedSegment struct to be stored on the stack without causing overly large stack sizes. Reviewers: alekseyshl, kubamracek, glider Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D35135 llvm-svn: 307688
* Fix a build failure due to r307541 (tsan_rtl_aarch64.S:54: Error: unknown ↵Kuba Mracek2017-07-101-1/+1
| | | | | | pseudo-op: `.'). llvm-svn: 307549
* Fix-up for r307540.Kuba Mracek2017-07-101-2/+2
| | | | llvm-svn: 307547
* [tsan] Add comments for the bool argument of ↵Kuba Mracek2017-07-102-9/+9
| | | | | | | | ThreadIgnoreBegin/ThreadIgnoreSyncBegin, NFC. Differential Revision: https://reviews.llvm.org/D35134 llvm-svn: 307545
* [tsan] Add a mapping for Darwin/AArch64Kuba Mracek2017-07-103-9/+50
| | | | | | | | This patch defines the TSan memory map and offsets for Darwin on AArch64. Differential Revision: https://reviews.llvm.org/D35147 llvm-svn: 307544
* [tsan] Port setjmp/longjmp assembly to Darwin/AArch64Kuba Mracek2017-07-104-26/+117
| | | | | | | | This patch ports the assembly file implementing TSan's setjmp support to AArch64 on Darwin. Differential Revision: https://reviews.llvm.org/D35143 llvm-svn: 307541
* [tsan] Add a max VM address check for Darwin/AArch64Kuba Mracek2017-07-101-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D35154 llvm-svn: 307540
* Update buildgo.sh to pass -isysroot on Darwin.Kuba Mracek2017-07-071-1/+1
| | | | llvm-svn: 307443
* [Sanitizers] Consolidate internal errno definitions.Alex Shlyapnikov2017-07-062-14/+6
| | | | | | | Move internal errno definitions to common to be shared by all sanitizers and to be used by allocators. llvm-svn: 307233
* MergeAlex Shlyapnikov2017-06-291-1/+1
| | | | llvm-svn: 306746
* [Sanitizers] Operator new() interceptors always die on allocation errorAlex Shlyapnikov2017-06-281-5/+8
| | | | | | | | | | | | | | | | | | | | | Summary: Operator new interceptors behavior is now controlled by their nothrow property as well as by allocator_may_return_null flag value: - allocator_may_return_null=* + new() - die on allocation error - allocator_may_return_null=0 + new(nothrow) - die on allocation error - allocator_may_return_null=1 + new(nothrow) - return null Ideally new() should throw std::bad_alloc exception, but that is not trivial to achieve, hence TODO. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34731 llvm-svn: 306604
* [tsan] Add missing include directory for test unittestsFrancis Ricci2017-06-271-0/+1
| | | | | | | | | | | | Summary: Required to fix standalone builds in some configurations Reviewers: kubamracek, zaks.anna Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D34631 llvm-svn: 306411
* [Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocatorAlex Shlyapnikov2017-06-201-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Move cached allocator_may_return_null flag to sanitizer_allocator.cc and provide API to consolidate and unify the behavior of all specific allocators. Make all sanitizers using CombinedAllocator to follow AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM happens. When OOM happens, turn allocator_out_of_memory flag on regardless of allocator_may_return_null flag value (it used to not to be set when allocator_may_return_null == true). release_to_os_interval_ms and rss_limit_exceeded will likely be moved to sanitizer_allocator.cc too (later). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34310 llvm-svn: 305858
* tsan: fix reading of mutex flagsDmitry Vyukov2017-06-131-1/+1
| | | | | | | SyncVar::IsFlagSet returns true if any flag is set. This is wrong. Check the actual requested flag. llvm-svn: 305281
* tsan: fix pedantic warningsDmitry Vyukov2017-06-131-3/+5
| | | | | | ISO C++ does not allow ?: with omitted middle operand llvm-svn: 305273
* [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-254-19/+51
| | | | | | | | | | 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
* [tsan] Update tsan test for r303084Vitaly Buka2017-05-161-1/+1
| | | | | | | Tail duplication changed number of pop instruction, but TSAN performance was not affected. llvm-svn: 303136
* [sanitizer] Change SizeClassAllocator32 to accept just one templateKostya Kortchinsky2017-05-151-6/+12
| | | | | | | | | | | | | | | | | | | | | Summary: With rL279771, SizeClassAllocator64 was changed to accept only one template instead of 5, for the following reasons: "First, this will make the mangled names shorter. Second, this will make adding more parameters simpler". This patch mirrors that work for SizeClassAllocator32. This is in preparation for introducing the randomization of chunks in the 32-bit SizeClassAllocator in a later patch. Reviewers: kcc, alekseyshl, dvyukov Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D33141 llvm-svn: 303071
* [tsan] Detect races on modifying accesses in Swift codeKuba Mracek2017-05-037-30/+77
| | | | | | | | This patch allows the Swift compiler to emit calls to `__tsan_external_write` before starting any modifying access, which will cause TSan to detect races on arrays, dictionaries and other classes defined in non-instrumented modules. Races on collections from the Swift standard library and user-defined structs and a frequent cause of subtle bugs and it's important that TSan detects those on top of existing LLVM IR instrumentation, which already detects races in direct memory accesses. Differential Revision: https://reviews.llvm.org/D31630 llvm-svn: 302050
* tsan: allow fast large MemoryRangeSet on non-Windows GoDmitry Vyukov2017-05-021-3/+2
| | | | | | | | | | | | The fast reset for large memory regions is not working only on windows. So enable it for Go/linux/darwin/freebsd. See https://github.com/golang/go/issues/20139 for background and motivation. Based on idea by Josh Bleecher Snyder. llvm-svn: 301927
* [compiler-rt] move tsan's Android __get_tls() to sanitizer_commonKostya Kortchinsky2017-05-021-19/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: TSan's Android `__get_tls()` and `TLS_SLOT_TSAN` can be used by other sanitizers as well (see D32649), this change moves them to sanitizer_common. I picked sanitizer_linux.h as their new home. In the process, add the 32-bit versions for ARM, i386 & MIPS. Can the address of `__get_tls()[TLS_SLOT_TSAN]` change in between the calls? I am not sure if there is a need to repeat the construct as opposed to using a variable. So I left things as they were. Testing on my side was restricted to a successful cross-compilation. Reviewers: dvyukov, kubamracek Reviewed By: dvyukov Subscribers: aemerson, rengolin, srhines, dberris, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D32705 llvm-svn: 301926
* [powerpc] deactivate flakey tests on powerpc64leBill Seurer2017-05-011-2/+3
| | | | | | | | | | | | | | | | | | | | These test cases occassionally fail when run on powerpc64le: ignore_lib1.cc ignore_lib5.cc TestCases/Posix/current_allocated_bytes.cc rtl/TsanRtlTest/Posix.ThreadLocalAccesses TestCases/Posix/coverage-fork-direct.cc The failures cause false problem reports to be sent to developers whose code had nothing to do with the failures. Reactivate them when the real problems are fixed. This could also be related to the same problems as with the tests ThreadedOneSizeMallocStressTest, ThreadedMallocStressTest, ManyThreadsTest, and several others that do not run reliably on powerpc. llvm-svn: 301798
* tsan: support linker init flag in __tsan_mutex_destroyDmitry Vyukov2017-05-013-4/+4
| | | | | | | | | | | | | | For a linker init mutex with lazy flag setup (no __tsan_mutex_create call), it is possible that no lock/unlock happened before the destroy call. Then when destroy runs we still don't know that it is a linker init mutex and will emulate a memory write. This in turn can lead to false positives as the mutex is in fact linker initialized. Support linker init flag in destroy annotation to resolve this. llvm-svn: 301795
* [tsan] Track external tags in thread tracesKuba Mracek2017-04-305-20/+62
| | | | | | | | To make the TSan external API work with Swift and other use cases, we need to track "tags" for individual memory accesses. Since there is no space to store this information in shadow cells, let's use the thread traces for that. This patch stores the tag as an extra frame in the stack traces (by calling FuncEntry and FuncExit with the address of a registered tag), this extra frame is then stripped before printing the backtrace to stderr. Differential Revision: https://reviews.llvm.org/D32382 llvm-svn: 301777
* [tsan] Remove the extra word "object" from description of external racesKuba Mracek2017-04-241-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D32383 llvm-svn: 301189
* [tsan] Refactor __tsan_external_read/__tsan_external_write to avoid code ↵Kuba Mracek2017-04-211-20/+16
| | | | | | | | | | duplication Let's introduce a ExternalAccess function that has the shared code only once. Differential Revision: https://reviews.llvm.org/D32360 llvm-svn: 301008
* [tsan] Track external API accesses as 1-byte accesses (instead of 8-byte)Kuba Mracek2017-04-211-2/+2
| | | | | | | | It doesn't really make sense to track them as 8-byte accesses. Differential Revision: https://reviews.llvm.org/D32359 llvm-svn: 301001
* [tsan] Ignore memory accesses for libignored modules for "external" racesKuba Mracek2017-04-213-7/+16
| | | | | | | | On Darwin, the setting ignore_noninstrumented_modules is used to suppress false positives in code that users don't have control of. The recently added "external" API (which can be used to detect races on objects provided by system libraries, but the race is actually user's fault) ignores this flag and it can report issues in non-instrumented modules. This patch fixes that. Differential Revision: https://reviews.llvm.org/D31553 llvm-svn: 301000
* [tsan] Don't report bugs from interceptors called from libignored modulesKuba Mracek2017-04-213-1/+4
| | | | | | | | This patch make sure we don't report deadlocks and other bug types when we're inside an interceptor that was called from a noninstrumented module (when ignore_noninstrumented_modules=1 is set). Adding a testcase that shows that deadlock detection still works on Darwin (to make sure we're not silencing too many reports). Differential Revision: https://reviews.llvm.org/D31449 llvm-svn: 300998
* [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek2017-04-175-7/+8
| | | | | | | | 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
* Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systemsFrancis Ricci2017-04-131-12/+2
| | | | | | | | | | | | | | | | | Summary: Lsan was using PTHREAD_CREATE_JOINABLE/PTHREAD_CREATE_DETACHED as truthy values, which works on Linux, where the values are 0 and 1, but this fails on OS X, where the values are 1 and 2. Set PTHREAD_CREATE_DETACHED to the correct value for a given system. Reviewers: kcc, glider, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31883 llvm-svn: 300221
OpenPOWER on IntegriCloud