summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "tsan: add fiber support"Diana Picus2019-02-135-97/+2
| | | | | | | This reverts commit r353817 because we think it broke AARch64 and PowerPC buildbots. llvm-svn: 353939
* [tsan] #undef one-letter macrosEvgeniy Stepanov2019-02-121-0/+8
| | | | | | | | buildgo.sh puts most of sanitizer_common together in a single source file. These single-letter macros end up affecting a lot of unrelated code; #undef them as early as possible. llvm-svn: 353902
* tsan: update check_analyze.shDmitry Vyukov2019-02-121-7/+1
| | | | | | | Update numbers after 353817. This was extensively benchmarked in https://reviews.llvm.org/D54889 llvm-svn: 353820
* tsan: add fiber supportDmitry Vyukov2019-02-125-2/+97
| | | | | | | | | | | | | | | | | This patch adds functions for managing fibers: __tsan_get_current_fiber() __tsan_create_fiber() __tsan_destroy_fiber() __tsan_switch_to_fiber() __tsan_set_fiber_name() See the added tests for use examples. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D54889 llvm-svn: 353817
* tsan: Introduce in_symbolizer() function for Thread sanitizerDmitry Vyukov2019-02-124-22/+28
| | | | | | | | | This change is preparation for fiber support. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D58104 llvm-svn: 353805
* tsan: Implement pthread_exit() interceptor for Thread sanitizerVitaly Buka2019-02-091-0/+8
| | | | | | | | | | | | This change is preparation for fiber support. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57876 Context: https://reviews.llvm.org/D54889 > llvm-svn: 353385 llvm-svn: 353627
* [tsan] Remove pthread_exit interceptorVitaly Buka2019-02-091-8/+0
| | | | | | Crashes PPC bot llvm-svn: 353604
* Fix Die() after pthread_exit call on macOSVitaly Buka2019-02-081-0/+3
| | | | | | | | | | | | | | | | | | | | Summary: Scoped interceptor should not be used when calling real pthread_exit(). On macOS C++ destructors are not called by pthread_exit(), and later check for empty thread ignore set fails. Patch by Yuri Per. Reviewers: dvyukov, vitalybuka Reviewed By: vitalybuka Subscribers: vitalybuka, thegameg, kubamracek, jfb, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D57963 llvm-svn: 353561
* [tsan] Remove SCOPED_TSAN_INTERCEPTOR to try to fix ppc botVitaly Buka2019-02-081-1/+0
| | | | llvm-svn: 353552
* tsan: add more benchmarksDmitry Vyukov2019-02-072-0/+100
| | | | | | | | | func_entry_exit.cc is for __tsan_func_entry/exit (spends ~75% there), we don't yet have any. mop.cc is for memory access functions, as compared to mini_bench_local/shared.cc this benchmark passes through deduplication logic (ContainsSameAccess). llvm-svn: 353407
* tsan: Optimize performance of Thread sanitizer memory access functionsDmitry Vyukov2019-02-074-18/+41
| | | | | | | | | | | | | | | | - Manually unwind code in MemoryAccessImpl1() because clang do not optimize it - Check for .rodata section only in read operations - Place LIKELY/UNLIKELY on fast paths This speeds up synthetic memory access benchmarks by 10-20%. [dvyukov: fixed up consts in check_analyze.sh] Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57882 Context: https://reviews.llvm.org/D54889 llvm-svn: 353401
* sanitizers: Introduce ThreadType enumDmitry Vyukov2019-02-079-10/+13
| | | | | | | | | | | | | Replace bool workerthread flag with ThreadType enum. This change is preparation for fiber support. [dvyukov: fixed build of sanitizer_thread_registry_test.cc] Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57839 Context: https://reviews.llvm.org/D54889 llvm-svn: 353390
* tsan: Implement pthread_exit() interceptor for Thread sanitizerDmitry Vyukov2019-02-071-0/+6
| | | | | | | | | | This change is preparation for fiber support. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57876 Context: https://reviews.llvm.org/D54889 llvm-svn: 353385
* [sanitizer] Don't unpoison buffer in getpw/getgr functionsVitaly Buka2019-02-071-13/+0
| | | | | | | | | | | | | | | | | Summary: Buffer should be referenced by results so used parts will be unpoisoned with unpoison_group and unpoison_passwd. This fixes TSAN performance issue made us to disable this interceptors. Reviewers: eugenis, dvyukov Subscribers: srhines, kubamracek, krytarowski, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D57731 llvm-svn: 353351
* [tsan] Disable fgetpwent_r to work around performance issuesVitaly Buka2019-02-041-0/+1
| | | | | | This was missed from D54041 when SANITIZER_INTERCEPT_FGETPWENT_R was branched from SANITIZER_INTERCEPT_GETPWENT_R llvm-svn: 353110
* Adjust documentation for git migration.James Y Knight2019-01-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes most references to the paths: llvm.org/svn/ llvm.org/git/ llvm.org/viewvc/ github.com/llvm-mirror/ github.com/llvm-project/ reviews.llvm.org/diffusion/ to instead point to https://github.com/llvm/llvm-project. This is *not* a trivial substitution, because additionally, all the checkout instructions had to be migrated to instruct users on how to use the monorepo layout, setting LLVM_ENABLE_PROJECTS instead of checking out various projects into various subdirectories. I've attempted to not change any scripts here, only documentation. The scripts will have to be addressed separately. Additionally, I've deleted one document which appeared to be outdated and unneeded: lldb/docs/building-with-debug-llvm.txt Differential Revision: https://reviews.llvm.org/D57330 llvm-svn: 352514
* On Darwin add allocator address and size fields toDan Liew2019-01-211-0/+1
| | | | | | | | | | | | | | `sanitizer_malloc_introspection_t` and initialize them to zero. We allow sanitizer implementations to perform different initialization by defining `COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT` to be `1` and providing an implementation of `mi_extra_init(...)`. We use these changes in future patches to implement malloc zone enumeration. rdar://problem/45284065 llvm-svn: 351712
* On Darwin allow for sanitizer malloc implementations to provide a zoneDan Liew2019-01-211-0/+1
| | | | | | | | | | | | | | | | enumerator. This is done by defining `COMMON_MALLOC_HAS_ZONE_ENUMERATOR` to `1` and then by providing an implementation of the `mi_enumerator(...)` function. If a custom implementation isn't desired the macro is set to `0` which causes a stub version (that fails) to be used. Currently all Darwin sanitizers that have malloc implementations define this to be `0` so there is no functionality change. rdar://problem/45284065 llvm-svn: 351711
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1984-336/+252
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [TSan] Use switches when dealing with enumsJulian Lettner2019-01-163-86/+87
| | | | | | | | | | | | | | | | | | Summary: Small refactoring: replace some if-else cascades with switches so that the compiler warns us about missing cases. Maybe found a small bug? Reviewers: dcoughlin, kubamracek, dvyukov, delcypher, jfb Reviewed By: dvyukov Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D56295 llvm-svn: 351288
* [TSan] Remove ignore_interceptors_accesses flagJulian Lettner2019-01-102-4/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: It has been superseded by the `ignore_noninstrumented_modules` flag and is no longer needed. Also simplify a test that checks that `mmap_interceptor` respects ignore annotations (`thr->ignore_reads_and_writes `). Relevant: https://reviews.llvm.org/rL269855 <rdar://problem/46263073> Remove obsolete Apple-specific suppression option Reviewers: dcoughlin, kubamracek, dvyukov, delcypher Reviewed By: dvyukov Subscribers: jfb, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55075 llvm-svn: 350883
* [sanitizer_common] Define __sanitizer_FILE on NetBSDMichal Gorny2019-01-101-10/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D56109 llvm-svn: 350882
* [TSan] Support Objective-C @synchronized with tagged pointersJulian Lettner2019-01-071-17/+31
| | | | | | | | | | | | | | | | | | | Summary: Objective-C employs tagged pointers, that is, small objects/values may be encoded directly in the pointer bits. The resulting pointer is not backed by an allocation/does not point to a valid memory. TSan infrastructure requires a valid address for `Acquire/Release` and `Mutex{Lock/Unlock}`. This patch establishes such a mapping via a "dummy allocation" for each encountered tagged pointer value. Reviewers: dcoughlin, kubamracek, dvyukov, delcypher Reviewed By: dvyukov Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D56238 llvm-svn: 350556
* [TSan] Enable detection of lock-order-inversions for Objective-C @synchronizedJulian Lettner2019-01-021-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: @synchronized semantics can be synthesized by using existing mutex_[un]lock operations. ``` @synchronized(obj) { // ... } => { mutex_lock(obj); // ... mutex_unlock(obj); } ``` Let me know whether you think this a good idea. Reviewers: dcoughlin, dvyukov, kubamracek, delcypher Reviewed By: dvyukov Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55959 llvm-svn: 350258
* [sanitizer_common] Implement popen, popenve, pclose interceptorsMichal Gorny2019-01-021-1/+2
| | | | | | | | | | | | | | | Implement the interceptors for popen(), pclose() and popenve() functions. The first two are POSIX, the third one is specific to NetBSD. popen() spawns a process and creates a FILE object piping data from/to that process. pclose() closes the pipe and waits for the process to terminate appropriately. For the purpose of popen(), the COMMON_INTERCEPTOR_FILE_OPEN macro is modified to allow null path parameter. Differential Revision: https://reviews.llvm.org/D56157 llvm-svn: 350232
* Introduce `AddressSpaceView` template parameter to `SizeClassAllocator64`.Dan Liew2018-12-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow up patch to r349138. This patch makes a `AddressSpaceView` a type declaration in the allocator parameters used by `SizeClassAllocator64`. For ASan, LSan, and the unit tests the AP64 declarations have been made templated so that `AddressSpaceView` can be changed at compile time. For the other sanitizers we just hard-code `LocalAddressSpaceView` because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55764 llvm-svn: 349954
* tsan: align default value of detect_deadlocks flag with actual behaviorDmitry Vyukov2018-12-191-2/+1
| | | | | | | | | | | | | | I tricked myself into thinking that deadlock detection is off by default in TSan by looking at the default value of the detect_deadlocks flag and outdated docs. (Created a pull request to update docs.) I even managed to confuse others: https://groups.google.com/forum/#!topic/thread-sanitizer/xYvnAYwtoDk However, the default value is overwritten in code (TSan_flags.cc:InitializeFlags). The TSan/deadlock tests also rely on this This changes aligns the default value of the flag with the actual default behavior. Author: yln (Julian Lettner) Reviewed in: https://reviews.llvm.org/D55846 llvm-svn: 349609
* Improve the comment in previousKamil Rytarowski2018-12-161-2/+2
| | | | llvm-svn: 349296
* Expand TSan sysroot workaround to NetBSDKamil Rytarowski2018-12-161-5/+6
| | | | | | https://bugs.llvm.org/show_bug.cgi?id=26651 llvm-svn: 349295
* Introduce `AddressSpaceView` template parameter to `SizeClassAllocator32`, ↵Dan Liew2018-12-141-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `FlatByteMap`, and `TwoLevelByteMap`. Summary: This is a follow up patch to r346956 for the `SizeClassAllocator32` allocator. This patch makes `AddressSpaceView` a template parameter both to the `ByteMap` implementations (but makes `LocalAddressSpaceView` the default), some `AP32` implementations and is used in `SizeClassAllocator32`. The actual changes to `ByteMap` implementations and `SizeClassAllocator32` are very simple. However the patch is large because it requires changing all the `AP32` definitions, and users of those definitions. For ASan and LSan we make `AP32` and `ByteMap` templateds type that take a single `AddressSpaceView` argument. This has been done because we will instantiate the allocator with a type that isn't `LocalAddressSpaceView` in the future patches. For the allocators used in the other sanitizers (i.e. HWAsan, MSan, Scudo, and TSan) use of `LocalAddressSpaceView` is hard coded because we do not intend to instantiate the allocators with any other type. In the cases where untemplated types have become templated on a single `AddressSpaceView` parameter (e.g. `PrimaryAllocator`) their name has been changed to have a `ASVT` suffix (Address Space View Type) to indicate they are templated. The only exception to this are the `AP32` types due to the desire to keep the type name as short as possible. In order to check that template is instantiated in the correct a way a `static_assert(...)` has been added that checks that the `AddressSpaceView` type used by `Params::ByteMap::AddressSpaceView` matches the `Params::AddressSpaceView`. This uses the new `sanitizer_type_traits.h` header. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: mgorny, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D54904 llvm-svn: 349138
* (no commit message)Julian Lettner2018-11-281-1/+1
| | | | llvm-svn: 347788
* tsan: Update measurements in check_analyze.sh.Peter Collingbourne2018-11-221-2/+2
| | | | | | | | | These changed as a result of r347379. Unfortunately there was a regression; filed PR39748 to track it. Differential Revision: https://reviews.llvm.org/D54821 llvm-svn: 347442
* tsan: Correct the name of an executable.Peter Collingbourne2018-11-221-1/+1
| | | | llvm-svn: 347439
* tsan: add pthread_tryjoin_np and pthread_timedjoin_np interceptorsDmitry Vyukov2018-11-213-0/+40
| | | | | | | | | | Add pthread_tryjoin_np() and pthread_timedjoin_np() interceptors on Linux, so that ThreadSanitizer can handle programs using these functions. Author: Yuri Per (yuri) Reviewed in: https://reviews.llvm.org/D54521 llvm-svn: 347383
* [tsan] Add __cxa_guard_acquire hooks to support cooperative schedulingVitaly Buka2018-11-201-0/+12
| | | | | | | | | | Reviewers: dvyukov Subscribers: krytarowski, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D54664 llvm-svn: 347336
* [sanitizer] Use "fast mmap" kernel flag for shadow memory on macOS 10.13.4+Kuba Mracek2018-11-061-1/+3
| | | | | | | | This speeds up process startup and teardown and also reduces lock contention when running multiple ASanified/TSanified processes simultaneously. Should greatly improve lit testing time. Differential Revision: https://reviews.llvm.org/D48445 llvm-svn: 346262
* Handle NetBSD alias for pthread_sigmaskKamil Rytarowski2018-10-302-0/+7
| | | | | | | | | | | | | | | | | | | | | Summary: Add a new helper macro TSAN_INTERCEPTOR_NETBSD_ALIAS_THR2 that handles pthread(3)/libc aliases in scenarios when a name in both libraries differs not just in prefix namespace. Handle TSan pthread_sigmask mangling accordingly into __libc_thr_sigsetmask. Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, jfb, llvm-commits, #sanitizers, mgorny Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D53863 llvm-svn: 345627
* Handle NetBSD symbol mangling for nanosleep and vforkKamil Rytarowski2018-10-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Native code generated on NetBSD mangles: - vfork into __vfork14 - nanosleep into __nanosleep50 Handle this accordingly in TSan. Reviewers: vitalybuka, dvyukov, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers, mgorny Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D53806 llvm-svn: 345570
* [TSan] Cleanup TSan runtime support for Go on linux-aarch64. NFC.Arnaud A. de Grandmaison2018-10-121-28/+10
| | | | | | | | | | | | | | | This is a follow-up patch to r342541. After further investigations, only 48bits VMA size can be supported. As this is enforced in function InitializePlatformEarly from lib/rt1/tsan_platform_linux.cc, the access to the global variable vmaSize variable + switch can be removed. This also addresses a comment from https://reviews.llvm.org/D52167. vmaSize of 39 or 42bits are not compatible with a Go program memory layout as the Go heap will not fit in the shadow memory area. Patch by: Fangming Fang <Fangming.Fang@arm.com> llvm-svn: 344329
* Switch syscall(2)/__syscall(2) calls to libc calls on NetBSDKamil Rytarowski2018-10-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When possible, switch syscall(2)/__syscall(2) calls to direct calls of internal libc symbols. Add a new function to detect address of a libc symbol of a function that could be intercepted. With the address detector in GetRealLibcAddress(), an optional interceptor of libc call will be bypassed. The original approach with syscall(2)/__syscall(2) wasn't portable across supported ABIs and CPU architectures. The indirect syscall interface is also a candidate for removal in future revisions of NetBSD, as the C language ABI is not a good domain for serialization of arbitrary functions arguments. Switch the following functions to libc calls: - internal_mmap() - internal_munmap() - internal_mprotect() - internal_close() - internal_open() - internal_read() - internal_write() - internal_ftruncate() - internal_stat() - internal_lstat() - internal_fstat() - internal_dup2() - internal_readlink() - internal_unlink() - internal_rename() - internal_sched_yield() - internal__exit() - internal_sleep() - internal_execve() - NanoTime() - internal_clock_gettime() - internal_waitpid() - internal_getpid() - internal_getppid() - internal_getdents() - internal_lseek() - internal_sigaltstack() - internal_fork() - internal_sigprocmask() - internal_sysctl() - internal_sigemptyset() - internal_sigfillset() - GetTid() - TgKill() This revision leaves room for refactoring in subsequent commits. Reviewers: vitalybuka, kcc, joerg Reviewed By: vitalybuka Subscribers: mgorny, fedor.sergeev, jfb, loverszhaokai, devnexen, kubamracek, llvm-commits, ro, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D51419 llvm-svn: 343523
* [compiler-rt][TSan] Add TSan runtime support for Go on linux-aarch64.Arnaud A. de Grandmaison2018-09-194-2/+72
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds TSan runtime support for Go on linux-aarch64 platforms. This enables people working on golang to implement their platform/language part of the TSan support. Basic testing is done with lib/tsan/go/buildgo.sh. Additional testing will be done as part of the work done in the Go project. It is intended to support other VMA sizes, except 39 which does not have enough bits to support the Go heap requirements. Patch by Fangming Fang <Fangming.Fang@arm.com>. Reviewers: kubamracek, dvyukov, javed.absar Subscribers: mcrosier, dberris, mgorny, kristof.beyls, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D52167 llvm-svn: 342541
* [TSan] Update test valuesVlad Tsyrklevich2018-09-121-4/+4
| | | | | | | | Similarly to before, D51985 again reduced the number of registers required for the read/write routines causing this test to fail on sanitizer-x86_64-linux-autoconf. llvm-svn: 342092
* [TSan] Update assembly test again.Matt Morehouse2018-09-041-4/+4
| | | | | | Previous commit incorrectly updated the read1 case. llvm-svn: 341384
* [TSan] Update assembly code check.Matt Morehouse2018-09-041-2/+2
| | | | | | | The new assembly makes our benchmark faster, so it should be safe to update the check. llvm-svn: 341381
* [tsan] Adjust setjmp/longjmp handling on Darwin for macOS MojaveKuba Mracek2018-08-214-4/+22
| | | | | | | | | | On macOS Mojave, the OS started using the XOR-by-a-secret-key scheme (same as glibc is alread doing) for storing the SP value in setjmp environment. We need to adjust for that to keep supporting setjmp/longjmp on latest Darwin. The patch is basically doing the same what we're already doing for glibc. rdar://problem/43542596 Differential Revision: https://reviews.llvm.org/D51064 llvm-svn: 340350
* Fixup for r340342: Avoid Block_release'ing the block since we're no longer ↵Kuba Mracek2018-08-211-1/+1
| | | | | | | | making a copy. rdar://problem/42242579 llvm-svn: 340347
* [tsan] Avoid calling Block_copy in the "sync" GCD interceptorsKuba Mracek2018-08-211-4/+1
| | | | | | | | | | The synchronous dispatch functions in GCD (dispatch_sync, dispatch_barrier_sync), don't make a copy of the passed block. To maintain binary compatibility, we should avoid doing that as well in TSan, as there's no reason to do that. The synchronous dispatch functions will not return before the block is actually executed. rdar://problem/42242579 Differential Revision: https://reviews.llvm.org/D50920 llvm-svn: 340342
* [tsan] Fix gcc pedantic warningDmitry Vyukov2018-07-261-16/+16
| | | | | | | | | Fix gcc (7.2.0) pedantic warning warning: extra ‘;’ [-Wpedantic] Author: jasonl220 (Jason Lovett) Review: https://reviews.llvm.org/D49817 llvm-svn: 338023
* [tsan] Fix crash in objc_sync_enter/objc_sync_exit when using an Obj-C ↵Kuba Mracek2018-07-241-2/+26
| | | | | | | | | | tagged pointer Objective-C tagged pointers (either bottom-most or top-most bit is 1) are valid Obj-C objects but are not valid pointers. Make sure we don't crash on them when used in objc_sync_enter/objc_sync_exit. Instead, let's synchronize on a global object. Differential Revision: https://reviews.llvm.org/D49707 llvm-svn: 337837
* sanitizers: consistently check result of MmapFixedNoReserveDmitry Vyukov2018-07-203-21/+19
| | | | | | | | | | | | | | | | MmapFixedNoReserve does not terminate process on failure. Failure to check its result and die will always lead to harder to debug crashes later in execution. This was observed in Go processes due to some address space conflicts. Consistently check result of MmapFixedNoReserve. While we are here also add warn_unused_result attribute to prevent such bugs in future and change return type to bool as that's what all callers want. Reviewed in https://reviews.llvm.org/D49367 llvm-svn: 337531
OpenPOWER on IntegriCloud