summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* Account for stack redzone when computing sp on darwinFrancis Ricci2017-05-121-0/+4
| | | | | | | | | | | thread_get_register_pointer_values handles the redzone computation automatically, but is marked as an unavailable API function. This patch replicates its logic accounting for the stack redzone on x86_64. Should fix flakiness in the use_stack_threaded test for lsan on darwin. llvm-svn: 302898
* [asan] Recommit of r301904: Add strndup/__strndup interceptorsPierre Gousseau2017-05-114-0/+66
| | | | | | | | | Fix undeclared __interceptor_malloc in esan_interceptors.cc Fix undeclared strnlen on OSX Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 302781
* Revert "Add dyld to sanitizer procmaps on darwin"Francis Ricci2017-05-102-80/+7
| | | | | | | | | This breaks several tests because we don't always have access to __cxa_guard functions This reverts commit 45eb470c3e9e8f6993a204e247c33d4092237efe. llvm-svn: 302693
* Revert "Disable static caching of dyld header on Go sanitizers"Francis Ricci2017-05-101-4/+0
| | | | | | | This is a problem on more than just the go sanitizers, so it's not a good enough fix for the issue. llvm-svn: 302692
* Disable static caching of dyld header on Go sanitizersFrancis Ricci2017-05-101-0/+4
| | | | | | This causes buildbot failures due to undefined __cxa_guard_acquire llvm-svn: 302681
* Add dyld to sanitizer procmaps on darwinFrancis Ricci2017-05-102-7/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Sanitizer procmaps uses dyld apis to iterate over the list of images in the process. This is much more performan than manually recursing over all of the memory regions in the process, however, dyld does not report itself in the list of images. In order to prevent reporting leaks from dyld globals and to symbolize dyld functions in stack traces, this patch special-cases dyld and ensures that it is added to the list of modules. This is accomplished by recursing through the memory map of the process until a dyld Mach header is found. While this recursion is expensive, it is run before the full set of images has been loaded in the process, so only a few calls are required. The result is cached so that it never needs to be searched for when the full process memory map exists, as this would be incredibly slow, on the order of minutes for leak sanitizer with only 25 or so libraries loaded. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32968 llvm-svn: 302673
* [asan] print the 'unexpected format specifier in printf interceptor' warning ↵Kostya Serebryany2017-05-031-4/+8
| | | | | | just once (came up in https://github.com/google/oss-fuzz/pull/562). Not touching a similar scanf warning -- for some reason it does not fire for me. llvm-svn: 302064
* [sanitizer] Intercept mcheck and mprobe on LinuxMaxim Ostapenko2017-05-032-0/+15
| | | | | | | | | This patch addresses https://github.com/google/sanitizers/issues/804. Users can use mcheck and mprobe functions to verify heap state so we should intercept them to avoid breakage of valid code. Differential Revision: https://reviews.llvm.org/D32589 llvm-svn: 302001
* [compiler-rt] move tsan's Android __get_tls() to sanitizer_commonKostya Kortchinsky2017-05-021-0/+40
| | | | | | | | | | | | | | | | | | | | | | 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
* Revert r301904 causing tsan test failure in x86_64-linux-autoconfPierre Gousseau2017-05-024-66/+0
| | | | llvm-svn: 301909
* [asan] Add strndup/__strndup interceptors if targeting linux.Pierre Gousseau2017-05-024-0/+66
| | | | | | Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 301904
* [sanitizer-coverage] add a deprecation note for the old sanitizer-coverage; ↵Kostya Serebryany2017-05-022-4/+7
| | | | | | remove a TODO printf llvm-svn: 301889
* [sanitizer-coverage] remove more stale codeKostya Serebryany2017-05-012-37/+0
| | | | llvm-svn: 301845
* [sanitizer-coverage] disable coverage_direct=1, will remove the code in a ↵Kostya Serebryany2017-05-011-0/+2
| | | | | | few weeks llvm-svn: 301826
* [Compiler-rt][MIPS] Fix assert introduce with commit rl301171.Nitesh Jain2017-04-251-1/+1
| | | | llvm-svn: 301307
* [asan] Use posix strerror_r interceptor on android.Evgeniy Stepanov2017-04-241-1/+1
| | | | | | This fixes a regression in r297315. llvm-svn: 301243
* [sanitizer] Cache SizeClassForTransferBatch in the 32-bit local cacheKostya Kortchinsky2017-04-241-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: `SizeClassForTransferBatch` is expensive and is called for every `CreateBatch` and `DestroyBatch`. Caching it means `kNumClasses` calls in `InitCache` instead. This should be a performance gain if more than `kNumClasses / 2` batches are created and destroyed during the lifetime of the local cache. I have chosen to fully remove the function and putting the code in `InitCache`, which is a debatable choice. In single threaded benchmarks leveraging primary backed allocations, this turns out to be a sizeable gain in performances (greater than 5%). In multithreaded benchmarks leveraging everything, it is less significant but still an improvement (about 1%). Reviewers: kcc, dvyukov, alekseyshl Reviewed By: dvyukov Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D32365 llvm-svn: 301184
* [asan] Optimize strchr for strict_string_checks=falseVitaly Buka2017-04-211-13/+9
| | | | | | | | | | | | | | Summary: strchr interceptor does not need to call strlen if strict_string_checks is not enabled. Unnecessary strlen calls affect python parser performance. Reviewers: eugenis, kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D32264 llvm-svn: 301027
* Revert r300889, r300906, r300935, r300939Diana Picus2017-04-211-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | At least one of the ARM bots is still broken: Command Output (stderr): -- /home/buildslave/buildslave/clang-cmake-armv7-a15-full/llvm/projects/compiler-rt/test/asan/TestCases/Posix/strchr.c:31:12: error: expected string not found in input // CHECK: strchr.c:[[@LINE-2]] ^ <stdin>:3:59: note: scanning from here ==16297==ERROR: AddressSanitizer: SEGV on unknown address 0xb5add000 (pc 0xb6dccaa4 bp 0xbe8c19c8 sp 0xbe8c1570 T0) ^ <stdin>:3:59: note: with expression "@LINE-2" equal to "29" ==16297==ERROR: AddressSanitizer: SEGV on unknown address 0xb5add000 (pc 0xb6dccaa4 bp 0xbe8c19c8 sp 0xbe8c1570 T0) ^ <stdin>:5:57: note: possible intended match here #0 0xb6dccaa3 in strlen /build/glibc-f8FFOS/glibc-2.23/string/../sysdeps/arm/armv6t2/strlen.S:82 Try to fix by reverting r300889 and subsequent fixes: Revert "[asan] Fix test by removing "The signal is caused" check." Revert "[asan] Fix test on ppc64le-linux by checking "UNKNOWN memory access"" Revert "[asan] Match BUS and SIGV to fix test on Darwin" Revert "[asan] Optimize strchr for strict_string_checks=false" llvm-svn: 300955
* sanitizer: fix crash with textdomain(NULL) interceptorKostya Serebryany2017-04-201-1/+1
| | | | | | | | | | | | | | | | | | Summary: The textdomain function accepts a NULL parameter (and should then return the current message domain). Add a check for this and include ASAN tests. Link: https://github.com/google/sanitizers/issues/787 Reviewers: m.guseva, kcc Reviewed By: kcc Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D32318 llvm-svn: 300924
* [asan] Optimize strchr for strict_string_checks=falseVitaly Buka2017-04-201-13/+9
| | | | | | | | | | | | | | Summary: strchr interceptor does not need to call strlen if strict_string_checks is not enabled. Unnecessary strlen calls affect python parser performance. Reviewers: eugenis, kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D32264 llvm-svn: 300889
* Define a suppression for known leaks on pthread_exit call.Alex Shlyapnikov2017-04-201-0/+11
| | | | | | | | | | | | Summary: Refer to D32194 for the context. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D32303 llvm-svn: 300886
* [sanitizer-coverage] remove more unused codeKostya Serebryany2017-04-192-20/+0
| | | | llvm-svn: 300780
* [sanitizer-coverage] remove run-time support for ↵Kostya Serebryany2017-04-192-107/+0
| | | | | | -fsanitize-coverage=indirect-calls llvm-svn: 300775
* [sanitizer-coverage] remove run-time support for -fsanitize-coverage=trace-bbKostya Serebryany2017-04-192-113/+0
| | | | llvm-svn: 300766
* Implement StopTheWorld for DarwinFrancis Ricci2017-04-191-1/+46
| | | | | | | | | | Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32189 llvm-svn: 300759
* [sanitizer-coverage] remove run-time support for the deprecated ↵Kostya Serebryany2017-04-192-119/+0
| | | | | | -fsanitize-coverage=8bit-counters llvm-svn: 300745
* Implement function to get registers from suspended thread on darwinFrancis Ricci2017-04-191-2/+43
| | | | | | | | | | Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32182 llvm-svn: 300691
* Implement suspended thread register count for darwinFrancis Ricci2017-04-181-2/+1
| | | | | | | | | | Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32165 llvm-svn: 300599
* Remove mips64 defines from darwin-specific fileFrancis Ricci2017-04-181-2/+2
| | | | | | | | | | Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits, arichardson Differential Revision: https://reviews.llvm.org/D32183 llvm-svn: 300598
* [sanitizer] Don't include <linux/user.h> in ↵Maxim Ostapenko2017-04-181-10/+6
| | | | | | | | | | | | | | | | | | | | | | | sanitizer_stoptheworld_linux_libcdep.cc on ARM Android Turned out that adding defined(_arm_) in sanitizer_stoptheworld_linux_libcdep.cc breaks android arm with some toolchains. .../llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:36:11: fatal error: 'linux/user.h' file not found # include <linux/user.h> // for pt_regs ^ 1 error generated. Context: #if SANITIZER_ANDROID && defined(__arm__) # include <linux/user.h> // for pt_regs #else This patch removes corresponding #if SANITIZER_ANDROID && defined(__arm__) and a bit rearranges adjacent сode. Differential Revision: https://reviews.llvm.org/D32128 llvm-svn: 300531
* [asan] Fixup for r300483 (which is a fixup for r300473).Evgeniy Stepanov2017-04-181-4/+5
| | | | | | Sanitizer Printf() does not know about %lu. llvm-svn: 300521
* Update suspended threads info to be compatible with darwinFrancis Ricci2017-04-173-35/+117
| | | | | | | | | | | | | | | Summary: On Darwin, we need to track thread and tid as separate values. This patch splits out the implementation of the suspended threads list to be OS-specific. Reviewers: glider, kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31474 llvm-svn: 300491
* Fixup for r300473: Use %lu on Linux for tid_t in format strings.Kuba Mracek2017-04-171-3/+3
| | | | llvm-svn: 300483
* [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek2017-04-179-22/+25
| | | | | | | | 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 read non-readable address ranges during lsan pointer scanningFrancis Ricci2017-04-176-10/+21
| | | | | | | | | | | | Summary: This specifically addresses the Mach-O zero page, which we cannot read from. Reviewers: kubamracek, samsonov, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32044 llvm-svn: 300456
* [ubsan] Use the correct tool name in diagnosticsVedant Kumar2017-04-143-11/+17
| | | | | | | | | | | | | | | When using ASan and UBSan together, the common sanitizer tool name is set to "AddressSanitizer". That means that when a UBSan diagnostic is printed out, it looks like this: SUMMARY: AddressSanitizer: ... This can confuse users. Fix it so that we always use the correct tool name when printing out UBSan diagnostics. Differential Revision: https://reviews.llvm.org/D32066 llvm-svn: 300358
* Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systemsFrancis Ricci2017-04-132-0/+7
| | | | | | | | | | | | | | | | | 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
* Cache size per class size in SizeClassAllocatorXLocalCache.Alex Shlyapnikov2017-04-131-4/+8
| | | | | | | | | | | | | | | Summary: Allocator::ClassIdToSize() is not free and calling it in every Allocate/Deallocate has noticeable impact on perf. Reapplying D31991 with the appropriate fixes. Reviewers: cryptoad Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D32024 llvm-svn: 300216
* Free zone name when destroying malloc zoneFrancis Ricci2017-04-131-0/+3
| | | | | | | | | | | | | | | Summary: The darwin interceptor for malloc_destroy_zone manually frees the zone struct, but does not free the name component. Make sure to free the name if it has been set. Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31983 llvm-svn: 300195
* Revert "Cache size per class size in SizeClassAllocatorXLocalCache."Diana Picus2017-04-131-8/+4
| | | | | | | This reverts commit r300107 because it broke the ARM and AArch64 buildbots. llvm-svn: 300180
* Cache size per class size in SizeClassAllocatorXLocalCache.Alex Shlyapnikov2017-04-121-4/+8
| | | | | | | | | | | | | | Summary: Allocator::ClassIdToSize() is not free and calling it in every Allocate/Deallocate has noticeable impact on perf. Reviewers: eugenis, kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D31991 llvm-svn: 300107
* Avoid calling SizeClassMap::MaxCachedHint on hot path, it's not free.Alex Shlyapnikov2017-04-121-1/+1
| | | | | | | | | | | | Summary: Remove unecessary SizeClassMap::MaxCachedHint call. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D31989 llvm-svn: 300103
* [msan] fix iconv interceptor. before the fix the interceptor failed to mark ↵Kostya Serebryany2017-04-121-1/+1
| | | | | | memory as initialized if iconv returned -1. Found in a hard way while fuzzing libxml2 :( llvm-svn: 300010
* Reapply "Enable LSan for arm Linux"Maxim Ostapenko2017-04-115-9/+87
| | | | | | This patch reapplies r299923 with typo fixed in BLX macros. llvm-svn: 299948
* Revert r299923, it doesn't build in bootstrap builds.Nico Weber2017-04-115-87/+9
| | | | | | | | | | | | | | | FAILED: lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.arm.dir/sanitizer_linux.cc.o lib/sanitizer_common/sanitizer_linux.cc:1340:24: error: invalid instruction BLX(ip) ^ lib/sanitizer_common/sanitizer_linux.cc:1313:19: note: expanded from macro 'BLX' # define BLX(R) "mov lr, pc; bx" #R "\n" ^ <inline asm>:6:13: note: instantiated into assembly here mov lr, pc; bxip ^~~~ llvm-svn: 299943
* [lsan] Enable LSan for arm LinuxMaxim Ostapenko2017-04-115-9/+87
| | | | | | | | This patch enables LSan for arm Linux. Differential Revision: https://reviews.llvm.org/D29586 llvm-svn: 299923
* [PPC64, Sanitizers] Proper stack frame for the thread spawned in internal_cloneAlex Shlyapnikov2017-04-101-24/+51
| | | | | | | | | | | | | | | Summary: Set up the proper stack frame for the thread spawned in internal_clone, the current code does not follow ABI (and causes SEGV trying to use this malformed frame). Reviewers: wschmidt Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D31555 llvm-svn: 299896
* Revert r299672: Add a virtual destructor to a class with virtual methods.Ivan Krasin2017-04-061-1/+0
| | | | | | | | Reason: breaks sanitizers builds. Original Differential Revision: https://reviews.llvm.org/D317 llvm-svn: 299679
* Add a virtual destructor to a class with virtual methods.Ivan Krasin2017-04-061-0/+1
| | | | | | | | | | | | | | | | | Summary: Recently, Clang enabled the check for virtual destructors in the presence of virtual methods. That broke the bootstrap build. Fixing it. Reviewers: pcc Reviewed By: pcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D31776 llvm-svn: 299672
OpenPOWER on IntegriCloud