summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-11-209-28/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: 253688
* [sanitizer] Implement internal_fork and internal_forkpty for OS XKuba Brecka2015-11-203-3/+26
| | | | | | | | On Linux, we have internal_fork that forks without invoking user's pthread_atfork handlers, which is important for spawning external symbolizers. Let's implement this for OS X as well (using __fork). This patch also adds internal_forkpty which re-implements forkpty and uses __fork in it as well. Differential Revision: http://reviews.llvm.org/D14869 llvm-svn: 253666
* Tell clang-format that (most) sanitizers are written using Google style guide.Alexey Samsonov2015-11-191-0/+1
| | | | llvm-svn: 253608
* [compiler-rt] [tsan] Enable intercept setjmp/longjmp for AArch64Adhemerval Zanella2015-11-161-0/+6
| | | | | | | | | | | | | | | This patch adds assembly routines to enable setjmp/longjmp for aarch64 on linux. It fixes: * test/tsan/longjmp2.cc * test/tsan/longjmp3.cc * test/tsan/longjmp4.cc * test/tsan/signal_longjmp.cc I also checked with perlbench from specpu2006 (it fails to run with missing setjmp/longjmp intrumentation). llvm-svn: 253205
* Reverting r253080 ([tsan] Don't demangle names not starting with "_Z").Kuba Brecka2015-11-141-3/+0
| | | | | | This caused bot failures on ARM, e.g. http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9068 llvm-svn: 253129
* [tsan] Don't demangle names not starting with "_Z"Kuba Brecka2015-11-131-0/+3
| | | | | | | | I noticed that when a symbol is named just "x", it gets demangled to "long long". On POSIX, AFAIK, mangled names always start with "_Z", so lets just require that. Differential Revision: http://reviews.llvm.org/D14637 llvm-svn: 253080
* [tsan] Add global symbolication support into AtosSymbolizerKuba Brecka2015-11-131-15/+40
| | | | | | | | This patch adds support for symbolication of globals (implements `SymbolizeData`) for `AtosSymbolizer` on OS X. Differential Revision: http://reviews.llvm.org/D14618 llvm-svn: 253015
* tsan: fix windows Go buildDmitry Vyukov2015-11-122-1/+3
| | | | | | | | | | | Go build does not link in whatever library provides these symbols: # runtime/race race_windows_amd64.syso:gotsan.cc:(.text+0x578f): undefined reference to `__sanitizer::DumpProcessMap()' race_windows_amd64.syso:gotsan.cc:(.text+0xee33): undefined reference to `EnumProcessModules' race_windows_amd64.syso:gotsan.cc:(.text+0xeeb9): undefined reference to `GetModuleInformation' llvm-svn: 252922
* tsan: fix windows Go buildDmitry Vyukov2015-11-121-0/+2
| | | | | | CompareModulesBase is an unused function. llvm-svn: 252907
* [tsan] Add global symbolication support into DlAddrSymbolizerKuba Brecka2015-11-121-2/+8
| | | | | | | | `DlAddrSymbolizer` is used on OS X when we're running inside a sandbox that prevents us from spawning an external symbolizer. This patch adds support for symbolication of globals (implements `SymbolizeData`) for `DlAddrSymbolizer`. Differential Revision: http://reviews.llvm.org/D14613 llvm-svn: 252899
* tsan: fix Go build on linuxDmitry Vyukov2015-11-121-1/+1
| | | | | | librt is not linked in in Go build. llvm-svn: 252877
* [asan] Remove system_malloc_zoneKuba Brecka2015-11-121-14/+3
| | | | | | | | This seems to be dead code – `system_malloc_zone` is initialized as null and we never assign to it. This code is apparently currently never executed (in ASan), but is causes trouble for the TSan OS X port. Let's replace the checks with `COMMON_MALLOC_ENTER` (`ENSURE_ASAN_INITED()`). Differential Revision: http://reviews.llvm.org/D14334 llvm-svn: 252876
* [sanitizer coverage] reset global counters in __sanitizer_reset_coverageKostya Serebryany2015-11-111-0/+6
| | | | llvm-svn: 252815
* Revert r252683 - "Sancov in C++."Diego Novillo2015-11-112-288/+0
| | | | | | | | This reverts commits r252683 and r252689. This tool should not live here. See http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/311862.html for discussion. llvm-svn: 252744
* Implement some TLS support for PowerPC64.Jay Foad2015-11-112-7/+33
| | | | | | | | | | | | Summary: This is enough to get the asan static_tls.cc test case working. Reviewers: eugenis, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14574 llvm-svn: 252738
* Fix #if tests for PTRACE_GETREGS and others.Jay Foad2015-11-111-3/+6
| | | | | | | | | | | | | | | | | | Summary: On PowerPC64 Linux PTRACE_GETREGS is a #define and PT_GETREGS is not. On other systems it's the other way round. Extend the #ifs to check for both PTRACE_* and PT_*. This fixes test/sanitizer_common/TestCases/Linux/ptrace.cc when msan is enabled for PowerPC64. Reviewers: zatrazz, kcc, eugenis, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14564 llvm-svn: 252730
* sanitizer: speedup coverage by 33%Dmitry Vyukov2015-11-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Atomic RMW is not necessary in InitializeGuardArray. It is supposed to run when no user code runs. And if user code runs concurrently, then the atomic RMW won't help anyway. So replace it with non-atomic RMW. InitializeGuardArray takes more than 50% of time during re2 fuzzing: real 0m47.215s 51.56% a.out a.out [.] __sanitizer_reset_coverage 6.68% a.out a.out [.] __sanitizer_cov 3.41% a.out a.out [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long) 1.79% a.out a.out [.] __asan::Allocator::Allocate(unsigned long, unsigned long, With this change: real 0m31.661s 26.21% a.out a.out [.] sanitizer_reset_coverage 10.12% a.out a.out [.] sanitizer_cov 5.38% a.out a.out [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long) 2.53% a.out a.out [.] __asan::Allocator::Allocate(unsigned long, unsigned long, That's 33% speedup. Reviewed in http://reviews.llvm.org/D14537 llvm-svn: 252715
* Implement `internal_start/join_thread` on Mac OS XIsmail Pazarbasi2015-11-111-2/+12
| | | | | | | | | | | | | | Summary: Depends on D9637 Test Plan: Reviewers: kcc, glider, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9638 llvm-svn: 252696
* Disabling sancov.cc on windows.Mike Aizatsky2015-11-111-2/+4
| | | | | | | | | It can't be built due to cxxabi missing. Will fix later. Differential Revision: http://reviews.llvm.org/D14559 llvm-svn: 252689
* Sancov in C++.Mike Aizatsky2015-11-112-0/+286
| | | | | | | | | | Summary: First batch of sancov.py rewrite in C++. Supports "-print" and "-covered_functions" commands. Differential Revision: http://reviews.llvm.org/D14356 llvm-svn: 252683
* [compiler-rt] [asan] Use same shadow offset for aarch64Adhemerval Zanella2015-11-091-11/+4
| | | | | | | | This patch makes ASAN for aarch64 use the same shadow offset for all currently supported VMAs (39 and 42 bits). The shadow offset is the same for 39-bit (36). llvm-svn: 252497
* [tsan] Fix build warnings on OS XKuba Brecka2015-11-051-1/+1
| | | | | | | | 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
* [Sanitizer] Use ReportMmapFailureAndDie() in all applicable mmap variants on ↵Alexey Samsonov2015-11-054-16/+12
| | | | | | Posix. llvm-svn: 252121
* Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"Juergen Ributzka2015-11-049-149/+28
| | | | | | | 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
* Asan: utility function to determine first wrongly poisoned byte inMike Aizatsky2015-11-041-1/+4
| | | | | | | | container. Differential Revision: http://reviews.llvm.org/D14341 llvm-svn: 252071
* Whitespace fixup for r252052. NFC.Kuba Brecka2015-11-041-1/+2
| | | | llvm-svn: 252053
* [tsan] Use malloc zone interceptors on OS X, part 1 (refactoring)Kuba Brecka2015-11-041-0/+349
| | | | | | | | TSan needs to use a custom malloc zone on OS X, which is already implemented in ASan. This patch is a refactoring patch (NFC) that extracts this from ASan into sanitizer_common, where we can reuse it in TSan. Reviewed at http://reviews.llvm.org/D14330 llvm-svn: 252052
* [tsan] Allow memchr interceptor to be used before initialization on OS XKuba Brecka2015-11-031-0/+2
| | | | | | | | On OS X, `memchr` is called on a newly created thread even before `__tsan_thread_start_func` is invoked, which means that the ThreadState object for that thread will not yet be initialized. Let's add `COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED` into the interceptor to simply call `internal_memchr` in these cases. Differential Revision: http://reviews.llvm.org/D14283 llvm-svn: 251935
* Reapply r251918 ("[tsan] Fix build errors for TSan on OS X").Kuba Brecka2015-11-034-43/+47
| | | | llvm-svn: 251920
* Revert r251918 ("[tsan] Fix build errors for TSan on OS X").Kuba Brecka2015-11-033-43/+42
| | | | llvm-svn: 251919
* [tsan] Fix build errors for TSan on OS XKuba Brecka2015-11-033-42/+43
| | | | | | | | | | 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
* Revert "Apply modernize-use-default to compiler-rt."Alexey Samsonov2015-10-301-2/+2
| | | | | | | | | | | | 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
* Sanitizer: define WIN32_LEAN_AND_MEANSaleem Abdulrasool2015-10-291-0/+1
| | | | | | | | Define WIN32_LEAN_AND_MEAN before including Windows.h. This is already being done in some places. This does it more broadly. This permits building ASAN on Linux for Winndows, as well as reduces the amount of included declarations. llvm-svn: 251649
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-10-289-28/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* sanitizer_common: be more verbose, when symbolizer is not found.Ivan Krasin2015-10-281-2/+4
| | | | | | | | | | | | | | | | | Summary: I have othen been stuck when I got an ASAN report, but no symbols are resolved. The reasons might be different, and it always requires a bit of detective work to track down. These more verbose error messages will help the users like me. Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14135 llvm-svn: 251553
* Revert "[asan] On OS X, log reports to syslog and os_trace"Anna Zaks2015-10-278-143/+25
| | | | | | | | This reverts commit 251447. (Which caused failures on a Linux bot.) llvm-svn: 251467
* [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-10-278-25/+143
| | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 251447
* [asan] On OS X, tag mapped regions with VM_MEMORY_ANALYSIS_TOOL tagAnna Zaks2015-10-271-0/+2
| | | | | | | | | | This will tag all mmapped memory sanitizers use with "Performance tool data" when viewed in vmmap. (Even though sanitizers are not performance tools, it's the best available match and better than having the unidentified objects.) http://reviews.llvm.org/D13609 llvm-svn: 251445
* [compiler-rt] Fix ptrace interceptor for aarch64Adhemerval Zanella2015-10-261-5/+14
| | | | | | | | | | | | | | This patch fixes the ptrace interceptor for aarch64. The PTRACE_GETREGSET ptrace syscall with with invalid memory might zero the iovec::iov_base field and then masking the subsequent check after the syscall (since it will be 0 and it will not trigger an invalid access). The fix is to copy the value on a local variable and use its value on the checks. The patch also adds more coverage on the Linux/ptrace.cc testcase by addding check for PTRACE_GETREGSET for both general and floating registers (aarch64 definitions added only). llvm-svn: 251331
* [compiler-rt] Enable ptrace sanitizer for armAdhemerval Zanella2015-10-264-7/+29
| | | | | | | | | | This patch enables the ptrace syscall interceptors for arm and adds support for both PTRACE_GETVFPREGS and PTRACE_SETVFPREGS used to get the VFP register from ARM. The ptrace tests is also updated with arm and PTRACE_GETVFPREGS tests. llvm-svn: 251321
* [sanitizer-coverage] introduce __sanitizer_get_total_unique_caller_callee_pairsKostya Serebryany2015-10-221-1/+7
| | | | llvm-svn: 251071
* [msan] Intercept process_vm_readv/writev.Evgeniy Stepanov2015-10-222-0/+35
| | | | llvm-svn: 251059
* [lsan] [aarch64] Add support for AArch64Adhemerval Zanella2015-10-211-1/+4
| | | | | | | | | | This patch add support for leak sanitizer for aarch64. Similar to MIPS it uses a SizeClassAllocator32 due VMA constraints (aarch64 currently supports 39 and 42-bit VMA). It also fixes the android build issue. llvm-svn: 250898
* Apply modernize-use-default to compiler-rt.Angel Garcia Gomez2015-10-201-2/+2
| | | | | | | | | | | | 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
* [msan] Intercept mincore.Evgeniy Stepanov2015-10-192-0/+19
| | | | llvm-svn: 250761
* [msan] Intercept pthread_getcancel*.Evgeniy Stepanov2015-10-192-0/+27
| | | | llvm-svn: 250752
* [asan] Zero initialize sem_t in sem_init.Evgeniy Stepanov2015-10-123-7/+29
| | | | | | | | | | Old version of sem_init (GLIBC_2.0) fails to initialize parts of sem_t that are used in sem_timedwait. This is fixed in GLIBC_2.1, but since ASan interceptors downgrade sem_* to the oldest available version, this can introduce bugs that are only present in sanitized build. Workaround by zero-initializing sem_t in sem_init. llvm-svn: 250113
* Revert "[lsan] [aarch64] Add support for AArch64"Evgeniy Stepanov2015-10-081-4/+1
| | | | | | | | | This reverts commit ea02fa45225c35613bfecab383fb526e24b74497 (r249337). Reason: broken "ninja AsanUnitTests" on Android/AArch64. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/20675/steps/build%20compiler-rt%20android%2Faarch64/logs/stdio llvm-svn: 249730
* Provide missing Internal{Alloc, Free} declarations for libbacktrace symbolizer.Alexey Samsonov2015-10-071-0/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Since r223145 we don't include sanitizer_allocator_internal.h into sanitizer_symbolizer.h, so we can have undefined reference to Internal{Alloc, Free} stuff into sanitizer_symbolizer_libbacktrace.cc under SANITIZER_CP_DEMANGLE macro. This patch simply includes appropriate header into sanitizer_symbolizer_libbacktrace.h to resolve the issue. Patch by Maxim Ostapenko! Reviewers: kcc, eugenis, samsonov Subscribers: llvm-commits, ygribov Differential Revision: http://reviews.llvm.org/D13429 llvm-svn: 249633
* [lsan] [aarch64] Add support for AArch64Adhemerval Zanella2015-10-051-1/+4
| | | | | | | | This patch add support for leak sanitizer for aarch64. Similar to MIPS it uses a SizeClassAllocator32 due VMA constraints (aarch64 currently supports 39 and 42-bit VMA). llvm-svn: 249337
OpenPOWER on IntegriCloud