summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* tsan: fix mac Go buildDmitry Vyukov2015-11-121-2/+2
| | | | | | cur_thread does not exist in Go. llvm-svn: 252874
* [tsan] Filter OS X architectures for unit testingKuba Brecka2015-11-121-1/+5
| | | | | | | | The TSan unit test build currently fails if we're also building the iOS parts of compiler-rt, because `TSAN_SUPPORTED_ARCH` contains ARM64. For unit tests, we need to filter this only to host architecture(s). Differential Revision: http://reviews.llvm.org/D14604 llvm-svn: 252873
* tsan: fix unused variable in Go buildDmitry Vyukov2015-11-111-6/+6
| | | | llvm-svn: 252746
* [tsan] Rename tsan_test_util_linux.cc to tsan_test_util_posix.ccKuba Brecka2015-11-112-2/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D14575 llvm-svn: 252741
* Fixing #include order in tsan_new_delete.cc. Follow-up commit for r252284.Kuba Brecka2015-11-111-1/+1
| | | | llvm-svn: 252735
* [tsan] Add TSan unit test support for OS XKuba Brecka2015-11-117-27/+92
| | | | | | | | This patch enables building and running TSan unit tests on OS X. Differential Revision: http://reviews.llvm.org/D14546 llvm-svn: 252731
* [tsan] Pass correct interposed function prefix to report functionIsmail Pazarbasi2015-11-111-1/+7
| | | | | | | | | | | | | | Summary: On Darwin, interposed functions are prefixed with "wrap_". On Linux, they are prefixed with "__interceptor_". Reviewers: dvyukov, samsonov, glider, kcc, kubabrecka Subscribers: zaks.anna, llvm-commits Differential Revision: http://reviews.llvm.org/D14512 llvm-svn: 252695
* [tsan] Enable new/delete C++ interceptors for OS XKuba Brecka2015-11-062-1/+9
| | | | | | | | This patch adds `tsan_new_delete.cc` into the OS X build. Differential Revision: http://reviews.llvm.org/D14424 llvm-svn: 252284
* Trying to fix the FreeBSD build breakage due to r251916.Kuba Brecka2015-11-061-1/+1
| | | | | | http://lab.llvm.org:8011/builders/sanitizer_x86_64-freebsd/builds/6395 llvm-svn: 252277
* [tsan] Fix build warnings on OS XKuba Brecka2015-11-051-1/+11
| | | | | | | | Fixing `tsan_interceptors.cc`, which on OS X produces a bunch of warnings about unused constants and functions. Differential Revision: http://reviews.llvm.org/D14381 llvm-svn: 252165
* Lint warning fixup for r252160 ("[tsan] Fix pthread_once interceptor for OS X").Kuba Brecka2015-11-051-1/+1
| | | | llvm-svn: 252163
* [tsan] Fix the memcpy interceptor to be memmove compatible on OS XKuba Brecka2015-11-051-1/+4
| | | | | | | | On OS X, memcpy and memmove are actually aliases of the same implementation, which means the interceptor of memcpy is also invoked when memmove is called. The current implementation of the interceptor uses `internal_memcpy` to perform the actual memory operation, which can produce an incorrect result when memmove semantics are expected. Let's call `internal_memmove` instead. Differential Revision: http://reviews.llvm.org/D14336 llvm-svn: 252162
* [tsan] Allow memmove interceptor to be used when TSan is not initializedKuba Brecka2015-11-051-3/+5
| | | | | | | | A call to memmove is used early during new thread initialization on OS X. This patch uses the `COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED` check, similarly to how we deal with other early-used interceptors. Differential Revision: http://reviews.llvm.org/D14377 llvm-svn: 252161
* [tsan] Fix pthread_once interceptor for OS XKuba Brecka2015-11-051-1/+5
| | | | | | | | TSan has a re-implementation of `pthread_once` in its interceptor, which assumes that the `pthread_once_t *once_control` pointer is actually pointing to a "storage" which is zero-initialized and used for the atomic operations. However, that's not true on OS X, where pthread_once_t is a structure, that contains a header (with a magic value) and the actual storage follows after that. This patch skips the header to make the interceptor work on OS X. Differential Revision: http://reviews.llvm.org/D14379 llvm-svn: 252160
* [tsan] Alternative ThreadState storage for OS XKuba Brecka2015-11-054-2/+70
| | | | | | | | This implements a "poor man's TLV" to be used for TSan's ThreadState on OS X. Based on the fact that `pthread_self()` is always available and reliable and returns a valid pointer to memory, we'll use the shadow memory of this pointer as a thread-local storage. No user code should ever read/write to this internal libpthread structure, so it's safe to use it for this purpose. We lazily allocate the ThreadState object and store the pointer here. Differential Revision: http://reviews.llvm.org/D14288 llvm-svn: 252159
* [tsan] Use malloc zone interceptors on OS X, part 2Kuba Brecka2015-11-056-8/+72
| | | | | | | | TSan needs to use a custom malloc zone on OS X, which is already implemented in ASan. This patch uses the sanitizer_common implementation in `sanitizer_malloc_mac.inc` for TSan as well. Reviewed at http://reviews.llvm.org/D14330 llvm-svn: 252155
* [TSan] Fix mmap/mmap64 interceptor signature.Alexey Samsonov2015-11-051-4/+4
| | | | | | | mmap() offset argument has type off_t, not unsigned. off_t is usually 64-bit on 64-bit Linux. llvm-svn: 252103
* Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"Juergen Ributzka2015-11-041-1/+0
| | | | | | | Looks like this commit is deadlocking the ASAN tests on the green dragon bot (http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA/). llvm-svn: 252076
* [tsan] Handle libdispatch worker threads on OS XKuba Brecka2015-11-046-13/+63
| | | | | | | | 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
* [tsan] Shadow memory setup for OS XKuba Brecka2015-11-045-108/+136
| | | | | | | | Updating the shadow memory initialization in `tsan_platform_mac.cc` to also initialize the meta shadow and to mprotect the memory ranges that need to be avoided. Differential Revision: http://reviews.llvm.org/D14324 llvm-svn: 252044
* Fixup for r251923 to fix a warning about an extra semicolon.Kuba Brecka2015-11-031-2/+2
| | | | llvm-svn: 251924
* Reapply r251916 ("[tsan] Port TSan interceptors on OS X").Kuba Brecka2015-11-031-36/+86
| | | | llvm-svn: 251923
* Revert r251916 ("[tsan] Port TSan interceptors on OS X").Kuba Brecka2015-11-031-151/+103
| | | | llvm-svn: 251922
* Reapply r251918 ("[tsan] Fix build errors for TSan on OS X").Kuba Brecka2015-11-032-1/+5
| | | | llvm-svn: 251920
* Revert r251918 ("[tsan] Fix build errors for TSan on OS X").Kuba Brecka2015-11-032-5/+1
| | | | llvm-svn: 251919
* [tsan] Fix build errors for TSan on OS XKuba Brecka2015-11-032-1/+5
| | | | | | | | | | This patch moves a few functions from `sanitizer_linux_libcdep.cc` to `sanitizer_posix_libcdep.cc` in order to use them on OS X as well. Plus a few more small build fixes. This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point. Differential Revision: http://reviews.llvm.org/D14235 llvm-svn: 251918
* [tsan] Port TSan interceptors on OS XKuba Brecka2015-11-031-103/+151
| | | | | | | | | | This patch modifies `tsan_interceptors.cc` to be buildable on OS X. Several of the intercepted methods are not available on OS X, so we need to `#if !SANITIZER_MAC` them. Plus a few other fixes, e.g. `pthread_yield` doesn't exist, let's use `internal_sched_yield` instead. This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point. Differential Revision: http://reviews.llvm.org/D14237 llvm-svn: 251916
* [tsan] CMake support for TSan on OS XKuba Brecka2015-11-031-45/+59
| | | | | | | | Hi, this patch adds a CMake flag called `COMPILER_RT_ENABLE_TSAN_OSX`, which is off by default. If enabled, the build system will be building the OS X version of the TSan runtime library (called `libclang_rt.tsan_osx_dynamic.dylib`). I'll submit patches that fix OS X build errors shortly. This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point. llvm-svn: 251915
* Revert "Apply modernize-use-default to compiler-rt."Alexey Samsonov2015-10-304-6/+10
| | | | | | | | | | | | 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
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-10-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When ASan currently detects a bug, by default it will only print out the text of the report to stderr. This patch changes this behavior and writes the full text of the report to syslog before we terminate the process. It also calls os_trace (Activity Tracing available on OS X and iOS) with a message saying that the report is available in syslog. This is useful, because this message will be shown in the crash log. For this to work, the patch makes sure we store the full report into error_message_buffer unconditionally, and it also strips out ANSI escape sequences from the report (they are used when producing colored reports). I've initially tried to log to syslog during printing, which is done on Android right now. The advantage is that if we crash during error reporting or the produced error does not go through ScopedInErrorReport, we would still get a (partial) message in the syslog. However, that solution is very problematic on OS X. One issue is that the logging routine uses GCD, which may spawn a new thread on its behalf. In many cases, the reporting logic locks threadRegistry, which leads to deadlocks. Reviewed at http://reviews.llvm.org/D13452 (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid build failures on Linux.) llvm-svn: 251577
* Apply modernize-use-default to compiler-rt.Angel Garcia Gomez2015-10-204-10/+6
| | | | | | | | | | | | 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
* [sanitizer] Move CheckVMASize after flag initializationAdhemerval Zanella2015-09-151-3/+1
| | | | llvm-svn: 247684
* [compiler-rt] [sanitizers] Add VMA size check at runtimeAdhemerval Zanella2015-09-111-0/+3
| | | | | | | | | This patch adds a runtime check for asan, dfsan, msan, and tsan for architectures that support multiple VMA size (like aarch64). Currently the check only prints a warning indicating which is the VMA built and expected against the one detected at runtime. llvm-svn: 247413
* tsan: speed up race deduplicationDmitry Vyukov2015-09-0311-108/+126
| | | | | | | | | | | | | | | | | | | | | | | Race deduplication code proved to be a performance bottleneck in the past if suppressions/annotations are used, or just some races left unaddressed. And we still get user complaints about this: https://groups.google.com/forum/#!topic/thread-sanitizer/hB0WyiTI4e4 ReportRace already has several layers of caching for racy pcs/addresses to make deduplication faster. However, ReportRace still takes a global mutex (ThreadRegistry and ReportMutex) during deduplication and also calls mmap/munmap (which take process-wide semaphore in kernel), this makes deduplication non-scalable. This patch moves race deduplication outside of global mutexes and also removes all mmap/munmap calls. As the result, race_stress.cc with 100 threads and 10000 iterations become 30x faster: before: real 0m21.673s user 0m5.932s sys 0m34.885s after: real 0m0.720s user 0m23.646s sys 0m1.254s http://reviews.llvm.org/D12554 llvm-svn: 246758
* [tsan] workaround for a crash in deadlock detector, bug ↵Kostya Serebryany2015-09-011-1/+1
| | | | | | https://github.com/google/sanitizers/issues/594 llvm-svn: 246592
* [compiler-rt] [tsan] Enable TSan for AArch64/42-bit VMAAdhemerval Zanella2015-08-282-4/+32
| | | | | | | | | | | This patch adds support for tsan on aarch64-linux with 42-bit VMA (current default config for 64K pagesize kernels). The support is enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time for both clang/llvm and compiler-rt. The default VMA is 39 bits. It also enabled tsan for previous supported VMA (39). llvm-svn: 246330
* [CMake] Add ARCHS option to add_sanitizer_rt_symbols.Chris Bieneman2015-08-271-2/+4
| | | | | | | | | | | | | | | | | Summary: This is another step in a multi-step refactoring to move add_sanitizer_rt_symbols in the direction of other add_* functions in compiler-rt. Changes to CMakeLists files are all minimal except ubsan which tests the new ARCHS loop. Further cleanup patches will follow. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12410 llvm-svn: 246199
* [sanitizer] Move sem_* to common interceptors.Evgeniy Stepanov2015-08-271-63/+6
| | | | llvm-svn: 246184
* [CMake] Converting add_sanitizer_rt_symbols to use cmake_parse_arguments.Chris Bieneman2015-08-261-2/+4
| | | | | | | | | | | | Summary: This is the first step in a multi-step refactoring to move add_sanitizer_rt_symbols in the direction of other add_* functions in compiler-rt. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12386 llvm-svn: 246102
* [CMake] merge add_compiler_rt_runtime and add_compiler_rt_darwin_runtime ↵Chris Bieneman2015-08-252-9/+17
| | | | | | | | | | | | | | | | into a single function Summary: This refactoring moves much of the Apple-specific behavior into a function in AddCompilerRT. The next cleanup patch will remove more of the if(APPLE) checks in the outlying CMakeLists. This patch adds a bunch of new functionality to add_compiler_rt_runtime so that the target names don't need to be reconstructed outside the call. It also updates some of the call sites to exercise the new functionality, but does not update all uses fully. Subsequent patches will further update call sites and move to using the new features. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: beanz, rengolin, llvm-commits Differential Revision: http://reviews.llvm.org/D12292 llvm-svn: 245970
* [TSan] Support __sanitizer_set_death_callback().Alexey Samsonov2015-08-222-2/+2
| | | | llvm-svn: 245776
* [Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across ↵Alexey Samsonov2015-08-215-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | all sanitizers. Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 llvm-svn: 245734
* tsan: don't report any bugs when report_bugs=0 flag is setDmitry Vyukov2015-08-211-0/+2
| | | | llvm-svn: 245720
* -Wdeprecated: Use noexcept rather than throw() where supportedDavid Blaikie2015-08-101-4/+4
| | | | | | | | | | Summary: I've copy/pasted the LLVM_NOEXCEPT definition macro goo from LLVM's Compiler.h. Is there somewhere I should put this in Compiler RT? Is there a useful header to define/share things like this? Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D11780 llvm-svn: 244453
* [tsan] Enable tsan for aarch64Adhemerval Zanella2015-08-055-7/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enabled TSAN for aarch64 with 39-bit VMA layout. As defined by tsan_platform.h the layout used is: 0000 4000 00 - 0200 0000 00: main binary 2000 0000 00 - 4000 0000 00: shadow memory 4000 0000 00 - 5000 0000 00: metainfo 5000 0000 00 - 6000 0000 00: - 6000 0000 00 - 6200 0000 00: traces 6200 0000 00 - 7d00 0000 00: - 7d00 0000 00 - 7e00 0000 00: heap 7e00 0000 00 - 7fff ffff ff: modules and main thread stack Which gives it about 8GB for main binary, 4GB for heap and 8GB for modules and main thread stack. Most of tests are passing, with the exception of: * ignore_lib0, ignore_lib1, ignore_lib3 due a kernel limitation for no support to make mmap page non-executable. * longjmp tests due missing specialized assembly routines. These tests are xfail for now. The only tsan issue still showing is: rtl/TsanRtlTest/Posix.ThreadLocalAccesses Which still required further investigation. The test is disable for aarch64 for now. llvm-svn: 244055
* [asan,tsan,msan] move the memcmp interceptor from asan/tsan to ↵Kostya Serebryany2015-07-291-16/+0
| | | | | | sanitizer_common. This may potentially lead to more reports from msan as it now sees the reads inside memcmp. To disable, use the flag intercept_memcmp=0. Likewise, it may potentially cause new races to appear due to more strict memcmp checking (flag strict_memcmp=1) llvm-svn: 243595
* tsan: fix shift overflowDmitry Vyukov2015-07-261-3/+3
| | | | | | | 3<<30 fits into 32-bit unsigned, but does not fit into int. Found by ubsan. llvm-svn: 243241
* __tsan::ThreadCreate takes incorrect value for detached argumentIsmail Pazarbasi2015-07-241-1/+9
| | | | | | | | | | | | | | | Summary: PTHREAD_CREATE_DETACHED has a different value on Mac OS X. Since both PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED are non-zero, `__tsan::ThreadCreate` always creates detached threads. Reviewers: kcc, samsonov, glider Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10606 llvm-svn: 243151
* [sanitizer] Implement logging to syslog.Evgeniy Stepanov2015-07-232-1/+2
| | | | | | | | | | | | | | | | | Previously, Android target had a logic of duplicating all sanitizer output to logcat. This change extends it to all posix platforms via the use of syslog, controlled by log_to_syslog flag. Enabled by default on Android, off everywhere else. A bit of cmake magic is required to allow Printf() to call a libc function. I'm adding a stub implementation to support no-libc builds like dfsan and safestack. This is a second attempt. I believe I've fixed all the issues that prompted the revert: Mac build, and all kinds of non-CMake builds (there are 3 of those). llvm-svn: 243051
* [sanitizer] Implement include_if_exists with process name substitution.Evgeniy Stepanov2015-07-211-1/+1
| | | | | | | | | include_if_exists=/path/to/sanitizer/options reads flags from the file if it is present. "%b" in the include file path (for both variants of the flag) is replaced with the basename of the main executable. llvm-svn: 242853
OpenPOWER on IntegriCloud