summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r251916 ("[tsan] Port TSan interceptors on OS X").Kuba Brecka2015-11-031-151/+103
| | | | llvm-svn: 251922
* [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: speed up race deduplicationDmitry Vyukov2015-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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
* [sanitizer] Move sem_* to common interceptors.Evgeniy Stepanov2015-08-271-63/+6
| | | | llvm-svn: 246184
* [TSan] Support __sanitizer_set_death_callback().Alexey Samsonov2015-08-221-1/+1
| | | | llvm-svn: 245776
* [tsan] Enable tsan for aarch64Adhemerval Zanella2015-08-051-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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::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
* [TSan] Fix dl_iterate_phdr callback for the case when info->dlpi_name is ↵Alexey Samsonov2015-07-101-4/+8
| | | | | | overwritten by user. llvm-svn: 241876
* tsan: fix handling of condition variable destructionDmitry Vyukov2015-06-301-2/+2
| | | | | | | | | | | | POSIX states that "It shall be safe to destroy an initialized condition variable upon which no threads are currently blocked", and later clarifies "A condition variable can be destroyed immediately after all the threads that are blocked on it are awakened) (in examples section). Tsan reported such destruction as a data race. Fixes https://llvm.org/bugs/show_bug.cgi?id=23616 Reviewed in http://reviews.llvm.org/D10693 llvm-svn: 241082
* [asan] Fix SanitizerCommon.PthreadDestructorIterations test on Android L.Evgeniy Stepanov2015-06-291-1/+1
| | | | | | | On Android L, TSD destructors run 8 times instead of 4. Back to 4 times on the current master branch (as well as on K). llvm-svn: 240992
* tsan: fix handling of dup2 Dmitry Vyukov2015-06-251-3/+3
| | | | | | | | | | | | Previously tsan modelled dup2(oldfd, newfd) as write on newfd. We hit several cases where the write lead to false positives: 1. Some software dups a closed pipe in place of a socket before closing the socket (to prevent races actually). 2. Some daemons dup /dev/null in place of stdin/stdout. On the other hand we have not seen cases when write here catches real bugs. So model dup2 as read on newfd instead. llvm-svn: 240687
* tsan: fix false positive between dlopen and dl_iterate_phdrDmitry Vyukov2015-06-241-0/+41
| | | | | | | | | We see false reports between dlopen and dl_iterate_phdr. This happens because tsan does not see dynamic linker internal synchronization. Unpoison module names in dl_iterate_phdr callback. llvm-svn: 240576
* [sanitizer] More string interceptors: strstr, strcasestr, strspn, strcspn, ↵Yury Gribov2015-05-281-11/+0
| | | | | | | | | | strpbrk. Patch by Maria Guseva. Differential Revision: http://reviews.llvm.org/D9017 llvm-svn: 238406
* [sanitizer] Recognize static TLS in __tls_get_addr interceptor.Evgeniy Stepanov2015-05-161-0/+8
| | | | | | | Current code tries to find the dynamic TLS header to the left of the TLS block without checking that it's not a static TLS allocation. llvm-svn: 237495
* [TSan] Move new/delete interceptors into a separate source file. NFC.Alexey Samsonov2015-04-271-93/+1
| | | | llvm-svn: 235906
* tsan: fix handling of pthread_detachDmitry Vyukov2015-04-201-1/+8
| | | | | | | | | | Fixes https://llvm.org/bugs/show_bug.cgi?id=23235 If pthread_create is followed by pthread_detach, the new thread may not acquire synchronize with the parent thread. llvm-svn: 235293
* tsan: handle async signals while blocked in pthread_cond_waitDmitry Vyukov2015-04-081-8/+29
| | | | | | Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=91 llvm-svn: 234394
* sanitizer: new "strict_string_checks" run-time flagDmitry Vyukov2015-04-061-3/+25
| | | | | | | | | | This patch is related to Issue 346: moar string interceptors: strstr, strcasestr, strcspn, strpbrk As was suggested in original review http://reviews.llvm.org/D6056 a new "strict_string_checks" run-time flag introduced. The flag support applied for existing common, asan, msan and tsan interceptors. New asan tests added. Change by Maria Guseva reviewed in http://reviews.llvm.org/D7123 llvm-svn: 234187
* tsan: fix munmap interceptorDmitry Vyukov2015-04-061-2/+5
| | | | | | | | | MetaMap::ResetRange/FreeRange rounds the range up to at least kMetaShadowSize. This is requried for e.g. free(malloc(0)). However, munmap returns EINVAL and do not unmap any memory when length arguments is equal to 0. So don't free meta shadow in this case as well. llvm-svn: 234145
* [Tsan] Do not sanitize memset() and other functions during initializationViktor Kutuzov2015-03-271-3/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D8544 llvm-svn: 233378
* [Tsan] Do not sanitize memcpy() during thread initialization on FreeBSDViktor Kutuzov2015-03-161-4/+7
| | | | | | Differential Revision: http://reviews.llvm.org/D8324 llvm-svn: 232381
* [Tsan] Adjust SA_SIGINFO and SIG_SETMASK values on FreeBSD.Viktor Kutuzov2015-03-121-4/+7
| | | | | | Differential Revision: http://reviews.llvm.org/D8176 llvm-svn: 232073
* tsan: fix crash during __tsan_java_moveDmitry Vyukov2015-03-121-0/+1
| | | | | | | | Munmap interceptor did not reset meta shadow for the range, and __tsan_java_move crashed because it encountered non-zero meta shadow for the destination. llvm-svn: 232029
* asan: fix signal handling during stoptheworldDmitry Vyukov2015-03-021-14/+14
| | | | | | | | | | | The problem is that without SA_RESTORER flag, kernel ignores the handler. So tracer actually did not setup any handler. Add SA_RESTORER flag when setting up handlers. Add a test that causes SIGSEGV in stoptheworld callback. Move SignalContext from asan to sanitizer_common to print better diagnostics about signal in the tracer thread. http://reviews.llvm.org/D8005 llvm-svn: 230978
* [Sanitizer] Refactor SuppressionContext class.Alexey Samsonov2015-02-201-2/+2
| | | | | | | | | | | | | | SuppressionContext is no longer a singleton, shared by all sanitizers, but a regular class. Each of ASan, LSan, UBSan and TSan now have their own SuppressionContext, which only parses suppressions specific to that sanitizer. "suppressions" flag is moved away from common flags into tool-specific flags, so the user now may pass ASAN_OPTIONS=suppressions=asan_supp.txt LSAN_OPIONS=suppressions=lsan_supp.txt in a single invocation. llvm-svn: 230026
* [TSan][MIPS64] Fix few more test cases for MIPS64Mohit K. Bhakkad2015-02-201-3/+3
| | | | | | | | | | | | Patch by Sagar Thakur Reviewers: dvyukov, samsonov, kcc. Subscribers: dsanders, mohit.bhakkad, Anand.Takale, llvm-commits. Differential Revision: http://reviews.llvm.org/D7290 llvm-svn: 230002
* [TSan][MIPS] Adding support for MIPS64Mohit K. Bhakkad2015-02-201-0/+25
| | | | | | | | | | | | Patch by Sagar Thakur Reviewers: dvyukov, samsonov, petarj, kcc, dsanders. Subscribers: mohit.bhakkad, Anand.Takale, llvm-commits. Differential Revision: http://reviews.llvm.org/D6291 llvm-svn: 229972
* [Sanitizer] Drop LibIgnore dependency on SuppressionContext. NFC.Alexey Samsonov2015-02-191-1/+7
| | | | | | | | Let each LibIgnore user (for now it's only TSan) manually go through SuppressionContext and pass ignored library templates to LibIgnore. llvm-svn: 229924
* [Sanitizers] Introduce GET_LINK_MAP_BY_DLOPEN_HANDLE() macroViktor Kutuzov2015-01-301-1/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D7233 llvm-svn: 227570
* [Sanitizers] Intercept opendir()Viktor Kutuzov2015-01-211-9/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D6968 llvm-svn: 226648
* Fix two extra semicolon warningsEhsan Akhgari2015-01-121-1/+1
| | | | | | | | | | Reviewers: timurrrr Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6890 llvm-svn: 225635
* tsan: intercept closedirDmitry Vyukov2014-12-191-0/+9
| | | | llvm-svn: 224575
* tsan: disable __tls_get_addr interceptorDmitry Vyukov2014-12-181-0/+10
| | | | | | see the added comments for details, it's messy llvm-svn: 224531
* tsan: fix data races between signal handler and sigactionDmitry Vyukov2014-12-181-17/+32
| | | | | | | signal handler reads sa_sigaction when a concurrent sigaction call can modify it as the result in could try to call SIG_DFL or a partially overwritten function pointer llvm-svn: 224530
* [asan] new flag: hard_rss_limit_mbKostya Serebryany2014-12-161-15/+2
| | | | llvm-svn: 224353
* [Sanitizer] Introduce Allocator::may_return_null bool flag.Alexey Samsonov2014-12-121-5/+1
| | | | | | | | | | | | | | | | | | | | Summary: Turn "allocator_may_return_null" common flag into an Allocator::may_return_null bool flag. We want to make sure that common flags are immutable after initialization. There are cases when we want to change this flag in the allocator at runtime: e.g. in unit tests and during ASan activation on Android. Test Plan: regression test suite, real-life applications Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6623 llvm-svn: 224148
* [Tsan] Do not flush all streams on exitViktor Kutuzov2014-12-021-6/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D6462 llvm-svn: 223121
* Fix -Wcast-qual warnings in sanitizersAlexey Samsonov2014-11-131-1/+2
| | | | llvm-svn: 221936
* [TSan] Use StackTrace from sanitizer_common where applicableAlexey Samsonov2014-11-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 221194
* [Tsan] Make calloc() to not track allocated space unless thread is ↵Viktor Kutuzov2014-10-271-0/+2
| | | | | | | | completely initialized Differential Revision: http://reviews.llvm.org/D5992 llvm-svn: 220673
* [Tsan] Do not intercept non-FreeBSD functions on FreeBSDViktor Kutuzov2014-10-241-25/+167
| | | | | | Differential Revision: http://reviews.llvm.org/D5858 llvm-svn: 220554
* [Tsan] Add FreeBSD support to longjmp-related definitionsViktor Kutuzov2014-10-211-0/+4
| | | | | | Differential Revision: http://reviews.llvm.org/D5857 llvm-svn: 220292
* [Tsan] Fix sigaction_t to match system definition on FreeBSDViktor Kutuzov2014-10-211-0/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D5856 llvm-svn: 220291
* tsan: remove dead codeDmitry Vyukov2014-10-151-60/+0
| | | | llvm-svn: 219779
* tsan: remove trailing whitespaceDmitry Vyukov2014-10-141-1/+1
| | | | llvm-svn: 219678
* tsan: refactor atexit handlingDmitry Vyukov2014-10-141-36/+53
| | | | | | | | | | The current handling (manual execution of atexit callbacks) is overly complex and leads to constant problems due to mutual ordering of callbacks. Instead simply wrap callbacks into our wrapper to establish the necessary synchronization. Fixes issue https://code.google.com/p/thread-sanitizer/issues/detail?id=80 llvm-svn: 219675
* [Tsan] Do not use INTERCEPT_FUNCTION_VER() on FreeBSDViktor Kutuzov2014-10-101-1/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D5708 llvm-svn: 219483
* [Tsan] Fix references to libc entities in tsan_interceptors.cc on FreeBSDViktor Kutuzov2014-10-091-0/+14
| | | | | | Differential Revision: http://reviews.llvm.org/D5663 llvm-svn: 219395
* tsan: more careful handling of signalsDmitry Vyukov2014-09-181-21/+33
| | | | | | | | | | | | | | | On some tests we see that signals are not delivered when a thread is blocked in epoll_wait. The hypothesis is that the signal is delivered right before epoll_wait call. The signal is queued as in_blocking_func is not set yet, and then the thread just blocks in epoll_wait forever. So double check pending signals *after* setting in_blocking_func. This way we either queue a signal and handle it in the beginning of a blocking func, or process the signal synchronously if it's delivered when in_blocking_func is set. llvm-svn: 218070
OpenPOWER on IntegriCloud