summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl
Commit message (Collapse)AuthorAgeFilesLines
...
* Ignore the DISPATCH_NOESCAPE if not definedYi Kong2017-12-281-0/+5
| | | | | | | | | | This macro is only defined after XCode 8, causing build breakage for build systems with prior versions. Ignore DISPATCH_NOESCAPE if not defined. Differential Revision: https://reviews.llvm.org/D41601 llvm-svn: 321543
* [MSan,TSan] Add aligned new/delete interceptors.Alex Shlyapnikov2017-12-221-0/+97
| | | | | | | | | | | | | | | Summary: Providing aligned new/delete implementations to match ASan. Unlike ASan, MSan and TSan do not perform any additional checks on overaligned memory, hence no sanitizer specific tests. Reviewers: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D41532 llvm-svn: 321365
* [TSan] Make more TSan interceptors symbolizer-aware.Alex Shlyapnikov2017-12-061-9/+25
| | | | | | | | | | | | | | | | | | Summary: Switching the rest of intercepted allocs to InternalAlloc (well, except __libc_memalign) when current thread is 'in_symbolizer'. Symbolizer might (and does) use allocation functions other than malloc/calloc/realloc. posix_memalign is the one actually used, others switched just in case (since the failure is obscure and not obvious to diagnose). Reviewers: dvyukov Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D40877 llvm-svn: 319929
* Move __tsan::Vector to __sanitizerKamil Rytarowski2017-12-049-146/+20
| | | | | | | | | | | | | | | | | | | | | 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
* [sanitizer] Refactor how assembly files are handledKuba Mracek2017-11-292-62/+62
| | | | | | | | This renames ASM_TSAN_SYMBOL and ASM_TSAN_SYMBOL_INTERCEPTOR to just ASM_SYMBOL and ASM_SYMBOL_INTERCEPTOR, because they can be useful in more places than just TSan. Also introduce a CMake function to add ASM sources to a target. Differential Revision: https://reviews.llvm.org/D40143 llvm-svn: 319339
* Defer StartBackgroundThread() and StopBackgroundThread() in TSanKamil Rytarowski2017-11-293-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: NetBSD cannot spawn new POSIX thread entities in early libc and libpthread initialization stage. Defer this to the point of intercepting the first pthread_create(3) call. This is the last change that makes Thread Sanitizer functional on NetBSD/amd64 without downstream patches. ******************** Testing Time: 64.91s ******************** Failing Tests (5): ThreadSanitizer-x86_64 :: dtls.c ThreadSanitizer-x86_64 :: ignore_lib5.cc ThreadSanitizer-x86_64 :: ignored-interceptors-mmap.cc ThreadSanitizer-x86_64 :: mutex_lock_destroyed.cc ThreadSanitizer-x86_64 :: vfork.cc Expected Passes : 290 Expected Failures : 1 Unsupported Tests : 83 Unexpected Failures: 5 Sponsored by <The NetBSD Foundation> Reviewers: joerg, eugenis, dvyukov, vitalybuka Reviewed By: dvyukov Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40583 llvm-svn: 319305
* Support the setjmp(3) family of functions in TSan/NetBSDKamil Rytarowski2017-11-282-26/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change adds support for the setjmp(3)/longjmp(3) family of functions on NetBSD. There are three types of them on NetBSD: - setjmp(3) / longjmp(3) - sigsetjmp(3) / sigsetjmp(3) - _setjmp(3) / _longjmp(3) Due to historical and compat reasons the symbol names are mangled: - setjmp -> __setjmp14 - longjmp -> __longjmp14 - sigsetjmp -> __sigsetjmp14 - siglongjmp -> __siglongjmp14 - _setjmp -> _setjmp - _longjmp -> _longjmp This leads to symbol renaming in the existing codebase. There is no such symbol as __sigsetjmp/__longsetjmp on NetBSD Add a comment that GNU-style executable stack note is not needed on NetBSD. The stack is not executable without it. 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/D40337 llvm-svn: 319189
* [PowerPC][tsan] Update tsan to handle changed memory layouts in newer kernelsBill Seurer2017-11-281-2/+2
| | | | | | | | | | | | In more recent Linux kernels with 47 bit VMAs the layout of virtual memory for powerpc64 changed causing the thread sanitizer to not work properly. This patch adds support for 47 bit VMA kernels for powerpc64. (second part) Tested on several 4.x and 3.x kernel releases. llvm-svn: 319180
* Correct mangled_sp on NetBSD/amd64 in TSanKamil Rytarowski2017-11-281-2/+4
| | | | | | | | | | | | The proper index is 6, not 2. Patch extracted from https://reviews.llvm.org/D40337 Reviewed and accepted by <dvyukov>. Sponsored by <The NetBSD Foundation> llvm-svn: 319163
* Handle symbol renaming of sigaction for NetBSDKamil Rytarowski2017-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: NetBSD uses the __sigaction14 symbol name for historical and compat reasons for the sigaction(2) function name. Rename the interceptors and users of sigaction to sigaction_symname and reuse it in the code base. This change fixes 4 failing tests in TSan/NetBSD: - ThreadSanitizer-x86_64 :: signal_errno.cc - ThreadSanitizer-x86_64 :: signal_malloc.cc - ThreadSanitizer-x86_64 :: signal_sync2.cc - ThreadSanitizer-x86_64 :: signal_thread.cc Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, eugenis, dvyukov, kcc Reviewed By: dvyukov Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40341 llvm-svn: 319160
* Correct NetBSD support in pthread_once(3)/TSanKamil Rytarowski2017-11-211-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The pthread_once(3)/NetBSD type is built with the following structure: struct __pthread_once_st { pthread_mutex_t pto_mutex; int pto_done; }; Set the pto_done position as shifted by __sanitizer::pthread_mutex_t_sz from the beginning of the pthread_once struct. This corrects deadlocks when the pthread_once(3) function is used. 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/D40262 llvm-svn: 318742
* [tsan] Fix sigaction implementation when it's called only to get handlerVitaly Buka2017-11-201-25/+27
| | | | | | | | | | Reviewers: eugenis Subscribers: kubamracek, llvm-commits, krytarowski Differential Revision: https://reviews.llvm.org/D40272 llvm-svn: 318707
* Try to fix syntax for !NetBSD in TSAN_INTERCEPTORsKamil Rytarowski2017-11-201-2/+2
| | | | llvm-svn: 318676
* Handle NetBSD specific indirection of libpthread functionsKamil Rytarowski2017-11-202-1/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Correct handling of libpthread(3) functions in TSan/NetBSD: - pthread_cond_init(3), - pthread_cond_signal(3), - pthread_cond_broadcast(3), - pthread_cond_wait(3), - pthread_cond_destroy(3), - pthread_mutex_init(3), - pthread_mutex_destroy(3), - pthread_mutex_trylock(3), - pthread_rwlock_init(3), - pthread_rwlock_destroy(3), - pthread_rwlock_rdlock(3), - pthread_rwlock_tryrdlock(3), - pthread_rwlock_wrlock(3), - pthread_rwlock_trywrlock(3), - pthread_rwlock_unlock(3), - pthread_once(3). Code out of the libpthread(3) context uses the libc symbols that are prefixed with __libc_, for example: __libc_cond_init. This caused that these functions were invisible to sanitizers on NetBSD. Intercept the libc-specific ones and add them as NetBSD-specific aliases for the common pthread(3) ones. NetBSD needs to intercept both functions, as the regularly named ones are used internally in libpthread(3). Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, vitalybuka Reviewed By: dvyukov Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40243 llvm-svn: 318673
* Update TSan/ARM64 max VM to 0xfc0000000 to reflect a kernel change.Kuba Mracek2017-11-131-4/+5
| | | | llvm-svn: 318103
* [tsan] Fix signal chainingVitaly Buka2017-11-131-2/+9
| | | | | | | | | | | | Summary: Return saved values only if installed sigaction is our wrapper. Reviewers: eugenis, dvyukov Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D39935 llvm-svn: 318082
* [tsan] Deadly signal handler for tsanVitaly Buka2017-11-132-21/+32
| | | | | | | | | | | | Summary: https://github.com/google/sanitizers/issues/637 Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D39929 llvm-svn: 318078
* [PowerPC][tsan] Update tsan to handle changed memory layouts in newer kernelsBill Seurer2017-11-131-36/+86
| | | | | | | | | | In more recent Linux kernels with 47 bit VMAs the layout of virtual memory for powerpc64 changed causing the thread sanitizer to not work properly. This patch adds support for 47 bit VMA kernels for powerpc64. Tested on several 4.x and 3.x kernel releases. llvm-svn: 318044
* [tsan] Move out more types to sanitizer_commonVitaly Buka2017-11-101-16/+13
| | | | | | https://github.com/google/sanitizers/issues/637 llvm-svn: 317946
* [compiler-rt] Fix const and volatile qualifier warningsKuba Mracek2017-11-102-12/+12
| | | | | | | | Building with a new clang produces a bunch of warnings about dropped 'const' and 'volatile' qualifiers on pointers. Let's fix them. Differential Revision: https://reviews.llvm.org/D39861 llvm-svn: 317929
* [tsan] Move code of sigaction_impl and signal_implVitaly Buka2017-11-101-50/+49
| | | | | | | | They need to be after sanitizer_signal_interceptors.inc to use READ function Part of https://github.com/google/sanitizers/issues/637 llvm-svn: 317914
* [tsan] Extract sigaction_impl and signal_implVitaly Buka2017-11-101-0/+13
| | | | | | | | Preparation for switching to sanitizer_signal_interceptors.inc Part of https://github.com/google/sanitizers/issues/637 llvm-svn: 317913
* [tsan] Use __sanitizer_siginfo from sanitizer_commonVitaly Buka2017-11-101-71/+25
| | | | llvm-svn: 317872
* [sanitizer] Remove references and hide CommonSanitizerReportMutexVitaly Buka2017-11-103-30/+38
| | | | llvm-svn: 317865
* Correct atexit(3) support in TSan/NetBSDKamil Rytarowski2017-11-081-12/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The NetBSD specific implementation of cxa_atexit() does not preserve the 2nd argument if dso is equal to NULL. Changes: - Split paths of handling intercepted __cxa_atexit() and atexit(3). This affects all supported Operating Systems. - Add a local stack-like structure to hold the __cxa_atexit() context. atexit(3) is documented in the C standard as calling callback from the earliest to the oldest entry. This path also fixes potential ABI problem of passing an argument to a function from the atexit(3) callback mechanism. - Add new test to ensure LIFO style of atexit(3) callbacks: atexit3.cc Proposal to change the behavior of __cxa_atexit() in NetBSD has been rejected. With the above changes TSan/NetBSD with the current tsan_interceptors.cc can bootstrap into operation. Sponsored by <The NetBSD Foundation> Reviewers: vitalybuka, dvyukov, joerg, kcc, eugenis Reviewed By: dvyukov Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39619 llvm-svn: 317735
* (NFC) Rename GetMax{,User}VirtualAddress.Evgeniy Stepanov2017-11-071-1/+1
| | | | | | | Future change will introduce GetMaxVirtualAddress that will not take the kernel area into account. llvm-svn: 317638
* tsan: allow usage of global vars with ctors in interceptorsDmitry Vyukov2017-11-071-13/+32
| | | | | | | | | | | | | | | | | We allow usage of global/per-thread data with non-trivial ctors/dtors throughout tsan code base by placing all global/per-thread data into Context/ThreadState and then explicitly constructing them with placement new. This greatly simplifies code by restricting the "linker initialized plague" to only these 2 objects. Do the same for interceptors data. This allows to use Vector instead of bunch of hand-written code in: https://reviews.llvm.org/D39619 Reviewed in: https://reviews.llvm.org/D39721 llvm-svn: 317587
* Late fixup in _lwp_exit on TSan/NetBSDKamil Rytarowski2017-11-031-1/+1
| | | | | | | | | | Call DestroyThreadState() before REAL(_lwp_exit)(); This variation is less racy. Sponsored by <The NetBSD Foundation> llvm-svn: 317369
* Correct detection of a thread terminationKamil Rytarowski2017-11-031-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Stop using the Linux solution with pthread_key_create(3). This approach does not work on NetBSD, because calling the thread destructor is not the latest operation on a POSIX thread entity. NetBSD's libpthread still calls at least pthread_mutex_lock and pthread_mutex_unlock. Detect _lwp_exit(2) call as it is really the latest operation called from a detaching POSIX thread. This resolves one set of crashes observed in the Thread Sanitizer execution. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, dvyukov, eugenis Reviewed By: vitalybuka Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39618 llvm-svn: 317363
* Disable detection of on_exit()/TSan on NetBSDKamil Rytarowski2017-11-031-2/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: NetBSD does not ship with on_exit() function. Introduce TSAN_MAYBE_INTERCEPT_ON_EXIT. It looks like this addition fixes build for Darwin. Sponsored by <The NetBSD Foundation> Reviewers: vitalybuka, joerg, eugenis, dvyukov, kcc Reviewed By: vitalybuka Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39617 llvm-svn: 317361
* Add NetBSD improvements in sanitizersKamil Rytarowski2017-10-253-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Changes: * Add initial msan stub support. * Handle NetBSD specific pthread_setname_np(3). * NetBSD supports __attribute__((tls_model("initial-exec"))), define it in SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE. * Add ReExec() specific bits for NetBSD. * Simplify code and add syscall64 and syscall_ptr for !NetBSD. * Correct bunch of syscall wrappers for NetBSD. * Disable test/tsan/map32bit on NetBSD as not applicable. * Port test/tsan/strerror_r to a POSIX-compliant OSes. * Disable __libc_stack_end on NetBSD. * Disable ReadNullSepFileToArray() on NetBSD. * Define struct_ElfW_Phdr_sz, detected missing symbol by msan. * Change type of __sanitizer_FILE from void to char. This helps to reuse this type as an array. Long term it will be properly implemented along with SANITIZER_HAS_STRUCT_FILE setting to 1. * Add initial NetBSD support in lib/tsan/go/buildgo.sh. * Correct referencing stdout and stderr in tsan_interceptors.cc on NetBSD. * Document NetBSD x86_64 specific virtual memory layout in tsan_platform.h. * Port tests/rtl/tsan_test_util_posix.cc to NetBSD. * Enable NetBSD tests in test/msan/lit.cfg. * Enable NetBSD tests in test/tsan/lit.cfg. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, eugenis, kcc, dvyukov Reviewed By: dvyukov Subscribers: #sanitizers, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39124 llvm-svn: 316591
* [tsan] Fix warnings in tsan_interceptors.cc from expansion of variadic macrosDmitry Vyukov2017-10-251-3/+3
| | | | | | | | | | | | C99 technically requires the rest arguments to be used in C variadic macros. This presents a problem with the macro SCOPED_TSAN_INTERCEPTOR when func takes no arguments. This happens with the function pause. Like other void argument functions, we pass in a fake argument to avoid this warning. Author: Alex Langford (xiaobai) Reviewed in: https://reviews.llvm.org/D39151 llvm-svn: 316558
* [tsan] Add Mutex annotation flag for constant-initialized ↵Dmitry Vyukov2017-10-202-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | __tsan_mutex_linker_init behavior Add a new flag, _⁠_tsan_mutex_not_static, which has the opposite sense of _⁠_tsan_mutex_linker_init. When the new _⁠_tsan_mutex_not_static flag is passed to _⁠_tsan_mutex_destroy, tsan ignores the destruction unless the mutex was also created with the _⁠_tsan_mutex_not_static flag. This is useful for constructors that otherwise woud set _⁠_tsan_mutex_linker_init but cannot, because they are declared constexpr. Google has a custom mutex with two constructors, a "linker initialized" constructor that relies on zero-initialization and sets ⁠_⁠_tsan_mutex_linker_init, and a normal one which sets no tsan flags. The "linker initialized" constructor is morally constexpr, but we can't declare it constexpr because of the need to call into tsan as a side effect. With this new flag, the normal c'tor can set _⁠_tsan_mutex_not_static, the "linker initialized" constructor can rely on tsan's lazy initialization, and _⁠_tsan_mutex_destroy can still handle both cases correctly. Author: Greg Falcon (gfalcon) Reviewed in: https://reviews.llvm.org/D39095 llvm-svn: 316209
* [sanitizer] Move the errno/ENOMEM allocator checks logic to separate .ccKostya Kortchinsky2017-10-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a new attempt at D38706, which had 2 issues. The first one was that it broke TSan, because `sanitizer_errno.h` was not directly included in `tsan_mman.cc`. This fixes the include. The second one was that it broke the nolibc build, because `__errno_location` couldn't be found. This adds the new .cc to the libcdep list instead of the base one. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D38743 llvm-svn: 315509
* tsan: handle signals in pause callDmitry Vyukov2017-09-281-0/+6
| | | | llvm-svn: 314384
* [tsan] Annotate function parameters with attribute 'noescape'.Akira Hatanaka2017-09-211-3/+5
| | | | | | | | | | | | | | | | | | This commit annotates the block parameters of the following functions declared in compiler-rt with 'noescape': - dispatch_sync - dispatch_barrier_sync - dispatch_once - dispatch_apply This is needed to commit the patch that adds support for 'noescape' in clang (see https://reviews.llvm.org/D32210) since these functions are annotated with 'noescape' in the SDK header files. Differential Revision: https://reviews.llvm.org/D32210 llvm-svn: 313929
* [compiler-rt] Cleanup decoratorsVitaly Buka2017-09-111-18/+11
| | | | | | | | | | | | | | Summary: Removed redundant End*() methods which defined same way. Removed redundant Warning() methods. Reviewers: eugenis Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D37549 llvm-svn: 312950
* Add NetBSD support in tsan_interceptors.ccKamil Rytarowski2017-08-301-11/+36
| | | | | | | | | | | | | | | | | | | Summary: NetBSD is a POSIX-like BSD Operating System. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, dvyukov, eugenis Reviewed By: dvyukov Subscribers: srhines, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D37305 llvm-svn: 312160
* tsan: don't pass bogus PCs to __tsan_symbolize_externalDmitry Vyukov2017-08-253-5/+27
| | | | | | | | See the added comment for an explanation. Reviewed in https://reviews.llvm.org/D37107 llvm-svn: 311768
* [tsan] Fix format string in WriteMemoryProfileKuba Mracek2017-08-071-2/+2
| | | | | | | | The current format string is broken and fails to parse. Differential Revision: https://reviews.llvm.org/D36192 llvm-svn: 310276
* [tsan] Check for pvalloc overlowKostya Kortchinsky2017-08-021-0/+4
| | | | | | | | | | | | | | | | | | Summary: `CheckForPvallocOverflow` was introduced with D35818 to detect when pvalloc would wrap when rounding up to the next multiple of the page size. Add this check to TSan's pvalloc implementation. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D36245 llvm-svn: 309897
* [Sanitizers] TSan allocator set errno on failure.Alex Shlyapnikov2017-07-246-37/+93
| | | | | | | | | | | | | | | | | | 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-222-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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-202-2/+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-202-0/+2
| | | | | | | | | | | | | | | | | 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-143-192/+484
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud