summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_mac.cc
AgeCommit message (Collapse)Author
2016-12-27[compiler-rt] Move logic which replace memcpy interceptor with memmove from ↵Vitaly Buka
asan to sanitizer_common. Reviewers: eugenis Subscribers: kubabrecka, dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D28074 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290626 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-26[asan] Support handle_sigill on DarwinKuba Mracek
Handling SIGILL on Darwin works fine, so let's just make this feature work and re-enable the ill.cc testcase. Differential Revision: https://reviews.llvm.org/D27141 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287959 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-26[asan] Add a "dump_registers" flag to print out CPU registers after a SIGSEGVKuba Mracek
This patch prints out all CPU registers after a SIGSEGV. These are available in the signal handler context. Only implemented for Darwin. Can be turned off with the dump_registers flag. Differential Revision: https://reviews.llvm.org/D11365 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287957 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28tsan: always define SANITIZER_GODmitry Vyukov
Currently we either define SANITIZER_GO for Go or don't define it at all for C++. This works fine with preprocessor (ifdef/ifndef/defined), but does not work for C++ if statements (e.g. if (SANITIZER_GO) {...}). Also this is different from majority of SANITIZER_FOO macros which are always defined to either 0 or 1. Always define SANITIZER_GO to either 0 or 1. This allows to use SANITIZER_GO in expressions and in flag default values. Also remove kGoMode and kCppMode, which were meant to be used in expressions, but they are not defined in sanitizer_common code, so SANITIZER_GO become prevalent. Also convert some preprocessor checks to C++ if's or ternary expressions. Majority of this change is done mechanically with: sed "s#ifdef SANITIZER_GO#if SANITIZER_GO#g" sed "s#ifndef SANITIZER_GO#if \!SANITIZER_GO#g" sed "s#defined(SANITIZER_GO)#SANITIZER_GO#g" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@285443 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-05[asan] Fixup: Switch to using dynamic shadow offset on iOSAnna Zaks
Address lint comments. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283378 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-05[asan] Reapply: Switch to using dynamic shadow offset on iOSAnna Zaks
The VM layout is not stable between iOS version releases, so switch to dynamic shadow offset. Differential Revision: https://reviews.llvm.org/D25218 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283375 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-05Revert "[asan] Switch to using dynamic shadow offset on iOS"Anna Zaks
This reverts commit b2af965b7924ad793b313996a96633bb72daf629. Revert as these changes broke a Chromium buildbot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283349 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-04[asan] Switch to using dynamic shadow offset on iOSAnna Zaks
The VM layout is not stable between iOS version releases, so switch to dynamic shadow offset. Differential Revision: https://reviews.llvm.org/D25218 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283240 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15[sanitizer] Fix darwin Go tsan build by unifying r281567 and r281553.Ahmed Bougacha
Avoid redefining the weak stub when building gotsan.cc git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281576 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15Define the weak symbol added by r281546 on mac.Ahmed Bougacha
'weak' doesn't behave like it does on linux. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281567 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-08[asan] Fix handle_abort_on_error.cc test on DarwinKuba Brecka
r280885 added a testcase for handle_abort, which is broken on macOS, let’s add this support into sanitizer_mac.cc. Differential Revision: https://reviews.llvm.org/D24344 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@280945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21[sanitizer] trying to fix Mac botsKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276346 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12More fixup for r269288 and r269296. Adding the missing 'return'.Kuba Brecka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269310 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12Fixup for r269288. SleepForSeconds is not available in nolibc builds, let's ↵Kuba Brecka
add an internal_sleep. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269296 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12[sanitizer] On OS X, exit the forked process gracefully when login_tty failsKuba Brecka
We're using forkpty to spawn the atos symbolizer. In some cases, login_tty (part of forkpty) can fail due to security measures (sandboxing). In this case, we should exit with a status code instead of completely crashing the spawned process. Even processing a failed CHECK() is problematic here, because we're post-fork and pre-exec where a lot of things don't work (for multithreaded processes, for OS X GUI apps, etc.). Differential Revision: http://reviews.llvm.org/D20048 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269289 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28[tsan] Fix Darwin GCD support after separation of Processor and ThreadStateKuba Brecka
Recent TSan changes (r267678) which factor out parts of ThreadState into a Processor structure broke worker threads on OS X. This fixes it by properly calling ProcCreate for GCD worker threads and by replacing some CHECKs with RAW_CHECK in early process initialization. CHECK() in TSan calls the allocator, which requires a valid Processor. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267864 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizers] read/write page fault detection on mac.Mike Aizatsky
Summary: Resubmit of http://reviews.llvm.org/D19495 enabled only on intel. Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19561 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267750 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix darwin Go supportDmitry Vyukov
os_trace turns out to be a macro that creates static object. Function-static objects use __cxa_atexit and __dso_handle which are not present in Go runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267720 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix darwin Go buildDmitry Vyukov
syslog_lock is not defined in Go build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267714 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix darwin Go buildDmitry Vyukov
Ifdef out global variables with destructors. This requires runtime support that is not provided by Go runtime (in particular _dso_handle symbol). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267709 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26Revert "[sanitizers] read/write page fault detection on mac."Mehdi Amini
This reverts commit r267477. It broke our bots that enables the AArch64 backends, it seems that this code is using a Darwin *X86 specific* field. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267526 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25[sanitizers] read/write page fault detection on mac.Mike Aizatsky
Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19495 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267477 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21[sanitizer] Use pthread_threadid_np as thread ID on OS XKuba Brecka
Let's use pthread_threadid_np which returns a more reasonable ID than pthread_self (which is actually a stack pointer). The numbers from pthread_threadid_np are already used in other tools, e.g. in LLDB, and often appear in logs, so it's much more useful than pthread_self. Differential Revision: http://reviews.llvm.org/D18951 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266991 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20[sanitizer] Fix 'dyld: Symbol not found: _dyldVersionNumber' link error on ↵Maxim Ostapenko
old Darwin systems. This patch fixes https://github.com/google/sanitizers/issues/669. On older Darwin systems (in particular, Darwin 10), dyld doesn't export '_dyldVersionNumber' symbol so we would have 'undefined reference' error in sanitzer library. Although sanitizers support was added to LLVM on OS X 10.7+ where '_dyldVersionNumber' symbol is already exported, GCC users still may want use them on older systems. Differential Revision: http://reviews.llvm.org/D19218 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266868 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24[tsan] Use direct syscalls for internal_mmap and internal_munmap on OS XKuba Brecka
On OS X, internal_mmap just uses mmap, which can invoke callbacks into libmalloc (e.g. when MallocStackLogging is enabled). This can subsequently call other intercepted functions, and this breaks our Darwin-specific ThreadState initialization. Let's use direct syscalls in internal_mmap and internal_munmap. Added a testcase. Differential Revision: http://reviews.llvm.org/D18431 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264259 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17Removing a non-intentional debug output that got committed in r263695.Kuba Brecka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263698 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17[sanitizer] On OS X, verify that interceptors work and abort if not, take 2Kuba Brecka
On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES. TSan unit tests run with a statically linked runtime, where interceptors don't work. To avoid aborting the process in this case, the patch replaces `DisableReexec()` with a weak `ReexecDisabled()` function which is defined to return true in unit tests. Differential Revision: http://reviews.llvm.org/D18212 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263695 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-15Revert r263551 due to a test failure.Kuba Brecka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263553 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-15[sanitizer] On OS X, verify that interceptors work and abort if notKuba Brecka
On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES. Differential Revision: http://reviews.llvm.org/D18121 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263551 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-22[Sanitizer] Introduce ListOfModules object and use it to replace ↵Alexey Samsonov
GetListOfModules(). Summary: This removes the hard limit on the number of loaded modules (used to be 16K), and makes it easier to use LoadedModules w/o causing a memory leak: ListOfModules owns the modules, and makes sure to properly clean them in destructor. Remove filtering functionality that is only needed in one place (LSan). Reviewers: aizatsky Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D17470 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@261554 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-08[asan] Implement SEGV read vs write detection for ARM and AArch64.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@260163 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-04[asan] When catching a signal caused by a memory access, print if it's a ↵Kostya Serebryany
READ or a WRITE. This touches win/mac files which I have not tested, if a win/mac bot fails I'll try to quick-fix git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-02[asan] Add iOS support.Anna Zaks
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259451 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26[sanitizers] execve & waitpid on mac.Mike Aizatsky
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258874 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-25Revert "[sanitizers] extracted process management functions"Mike Aizatsky
This reverts commit e5b34d5a2bf4c882bc647dd26a8cea2adc76f63c. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258713 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-25[sanitizers] extracted process management functionsMike Aizatsky
Differential Revision: http://reviews.llvm.org/D16542 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258710 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-18[asan] Optionally print reproducer cmdline in ASan reports.Maxim Ostapenko
Differential Revision: http://reviews.llvm.org/D16070 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258037 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-06[sanitizers] Log all output to CrashReport on OS XAnna Zaks
Log all of sanitizers' output (not just ASan bug reports) to CrashReport, which simplifies diagnosing failed checks as well as other errors. This also allows to strip the color sequences early from the printed buffer, which is more efficient than what we had perviously. Differential Revision: http://reviews.llvm.org/D15396 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256988 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04[libsanitizer] Fix bugs and wiki links to point to GitHub.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254738 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03[sanitizer] Replace a local array with InternalScopedString in MaybeReexec()Kuba Brecka
`MaybeReexec` contains a 1024-byte long local array, which produces a warning about frame size: .../lib/sanitizer_common/sanitizer_mac.cc:548:6: warning: stack frame size of 1132 bytes in function '__sanitizer::MaybeReexec' [-Wframe-larger-than=] Let's replace it with InternalScopedString. Differential Revision: http://reviews.llvm.org/D15181 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254619 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03[tsan] Use re-exec method to enable interceptors on older versions of OS XKuba Brecka
In AddressSanitizer, we have the MaybeReexec method to detect when we're running without DYLD_INSERT_LIBRARIES (in which case interceptors don't work) and re-execute with the environment variable set. On OS X 10.11+, this is no longer necessary, but to have ThreadSanitizer supported on older versions of OS X, let's use the same method as well. This patch moves the implementation from `asan/` into `sanitizer_common/`. Differential Revision: http://reviews.llvm.org/D15123 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254600 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20 [asan] On OS X, write error reports into Crash Report.Anna Zaks
The Crash Report is going to add app specific info if it is stored in the magical buffer. Differential Revision: http://reviews.llvm.org/D14791 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253691 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20[asan] Fix the deadlocks introduced by "On OS X, log reports to syslog and ↵Anna Zaks
os_trace" commit [asan] On OS X, log reports to syslog and os_trace, has been reverted in r252076 due to deadlocks on earlier versions of OS X. Alexey has also noticed deadlocks in some corner cases on Linux. This patch, if applied on top of the logging patch (http://reviews.llvm.org/D13452), addresses the known deadlock issues. (This also proactively removes the color escape sequences from the error report buffer since we have to copy the buffer anyway.) Differential Revision: http://reviews.llvm.org/D14470 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253689 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks
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.) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253688 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20[sanitizer] Implement internal_fork and internal_forkpty for OS XKuba Brecka
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253666 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11Implement `internal_start/join_thread` on Mac OS XIsmail Pazarbasi
Summary: Depends on D9637 Test Plan: Reviewers: kcc, glider, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9638 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252696 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"Juergen Ributzka
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/). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252076 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks
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.) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251577 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-27Revert "[asan] On OS X, log reports to syslog and os_trace"Anna Zaks
This reverts commit 251447. (Which caused failures on a Linux bot.) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251467 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-27[asan] On OS X, log reports to syslog and os_traceAnna Zaks
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251447 91177308-0d34-0410-b5e6-96231b3b80d8