summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_common.h
Commit message (Collapse)AuthorAgeFilesLines
...
* [sanitizer] rename MmapNoAccess to MmapFixedNoAccess; NFCKostya Serebryany2016-04-221-2/+2
| | | | llvm-svn: 267253
* Fix a load of -Wunknown-pragma warnings from clang-clReid Kleckner2016-04-011-2/+2
| | | | llvm-svn: 265152
* [sanitizer] On OS X, verify that interceptors work and abort if not, take 2Kuba Brecka2016-03-171-1/+0
| | | | | | | | | | 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 llvm-svn: 263695
* [Sanitizer] Protect against compiler-inserted memcpy() in ↵Alexey Samsonov2016-02-251-1/+1
| | | | | | InternalMmapVector::push_back(). llvm-svn: 261909
* [Sanitizer] Introduce ListOfModules object and use it to replace ↵Alexey Samsonov2016-02-221-10/+27
| | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 261554
* [asan] Implement SEGV read vs write detection for ARM and AArch64.Evgeniy Stepanov2016-02-081-6/+13
| | | | llvm-svn: 260163
* [asan] When catching a signal caused by a memory access, print if it's a ↵Kostya Serebryany2016-02-041-3/+8
| | | | | | 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 llvm-svn: 259741
* [asan] Add iOS support.Anna Zaks2016-02-021-1/+1
| | | | llvm-svn: 259451
* [sanitizers] generating html report on coverage dumpMike Aizatsky2016-01-271-0/+3
| | | | | | | | Subscribers: tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D16374 llvm-svn: 258999
* [cfi] Support for dlopen and dlclose.Evgeniy Stepanov2016-01-261-0/+1
| | | | | | Add dlopen/dlclose interceptors to update CFI shadow for loaded/unloaded libraries. llvm-svn: 258857
* [sanitizers] extracted process management functionsMike Aizatsky2016-01-261-0/+28
| | | | | | Differential Revision: http://reviews.llvm.org/D16546 llvm-svn: 258849
* Revert "[sanitizers] extracted process management functions"Mike Aizatsky2016-01-251-23/+0
| | | | | | This reverts commit e5b34d5a2bf4c882bc647dd26a8cea2adc76f63c. llvm-svn: 258713
* [sanitizers] extracted process management functionsMike Aizatsky2016-01-251-0/+23
| | | | | | Differential Revision: http://reviews.llvm.org/D16542 llvm-svn: 258710
* [asan] Optionally print reproducer cmdline in ASan reports.Maxim Ostapenko2016-01-181-0/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D16070 llvm-svn: 258037
* Introduce stats and stats_client libraries.Peter Collingbourne2016-01-161-0/+13
| | | | | | | | | This is part of a new statistics gathering feature for the sanitizers. See clang/docs/SanitizerStats.rst for further info and docs. Differential Revision: http://reviews.llvm.org/D16176 llvm-svn: 257972
* sanitizer_common: C++ify the IntrusiveList iterator interface.Peter Collingbourne2016-01-151-2/+1
| | | | llvm-svn: 257858
* [sanitizers] Log all output to CrashReport on OS XAnna Zaks2016-01-061-2/+2
| | | | | | | | | | | 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 llvm-svn: 256988
* [asan] Remove the use of system properties on Android.Evgeniy Stepanov2015-12-041-2/+0
| | | | | | | | | | | | | System properties are not accessible through NDK (we've been using hacks to get to them) and they are unavailable during ASan initialization in .preinit_array. Use environment variables and files instead (ex. ASAN_OPTIONS=include_if_exists=/path). No test changes. This feature was not tested because the properties are system-wide and would conflict with the parallel test runner. Yet another reason to get rid of it. llvm-svn: 254783
* [tsan] Use re-exec method to enable interceptors on older versions of OS XKuba Brecka2015-12-031-0/+3
| | | | | | | | 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 llvm-svn: 254600
* [asan] Fix the deadlocks introduced by "On OS X, log reports to syslog and ↵Anna Zaks2015-11-201-5/+11
| | | | | | | | | | | | 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 llvm-svn: 253689
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-11-201-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Use ReportMmapFailureAndDie() in all applicable mmap variants on ↵Alexey Samsonov2015-11-051-1/+1
| | | | | | Posix. llvm-svn: 252121
* Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"Juergen Ributzka2015-11-041-17/+2
| | | | | | | 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
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-10-281-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "[asan] On OS X, log reports to syslog and os_trace"Anna Zaks2015-10-271-17/+2
| | | | | | | | 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-271-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [compiler-rt] [sanitizers] Add VMA size check at runtimeAdhemerval Zanella2015-09-111-0/+2
| | | | | | | | | This patch adds a runtime check for asan, dfsan, msan, and tsan for architectures that support multiple VMA size (like aarch64). Currently the check only prints a warning indicating which is the VMA built and expected against the one detected at runtime. llvm-svn: 247413
* [Sanitizers] Allow to install several internal Die callbacks.Alexey Samsonov2015-08-241-3/+10
| | | | | | | | | | | | | | | | | This is required to properly re-apply r245770: 1) We should be able to dump coverage in __sanitizer::Die() if coverage collection is turned on. 2) We don't want to explicitly do this in every single sanitizer that supports it. 3) We don't want to link in coverage (and therefore symbolization) bits into small sanitizers that don't support it (safestack). The solution is to make InitializeCoverage() register its own Die() callback that would call __sanitizer_cov_dump(). This callback should be executed in addition to another tool-specific die callbacks (if there are any). llvm-svn: 245889
* Revert r245770 and r245777.Alexey Samsonov2015-08-221-1/+0
| | | | | | | These changes break both autoconf Mac OS X buildbot (linker errors due to wrong Makefiles) and CMake buildbot (safestack test failures). llvm-svn: 245784
* [Sanitizer] Dump coverage if we're killing the program with __sanitizer::Die().Alexey Samsonov2015-08-221-0/+1
| | | | | | | Previously we had to call __sanitizer_cov_dump() from tool-specific callbacks - instead, let sanitizer_common library handle this in a single place. llvm-svn: 245770
* [windows] Fix deadlock on mmap failure due to CHECK recursionReid Kleckner2015-08-121-0/+2
| | | | | | | | | | | | | | | | | | | Summary: Printing a stacktrace acquires a spinlock, and the sanitizer spinlocks aren't re-entrant. Avoid the problem by reusing the logic we already have on Posix. This failure mode is already exercised by the existing mmap_limit_mb.cc test case. It will be enabled in a forthcoming change, so I didn't add standalone tests for this change. Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11999 llvm-svn: 244840
* [asan] Print VAs instead of RVAs for module offsets on WindowsReid Kleckner2015-08-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is consistent with binutils and ASan behavior on other platforms, and makes it easier to use llvm-symbolizer with WinASan. The --relative-address flag to llvm-symbolizer is also no longer needed. An RVA is a "relative virtual address", meaning it is the address of something inside the image minus the base of the mapping at runtime. A VA in this context is an RVA plus the "preferred base" of the module, and not a real runtime address. The real runtime address of a symbol will equal the VA iff the module is loaded at its preferred base at runtime. On Windows, the preferred base is stored in the ImageBase field of one of the PE file header, and this change adds the necessary code to extract it. On Linux, this offset is typically included in program and section headers of executables. ELF shared objects typically use a preferred base of zero, meaning the smallest p_vaddr field in the program headers is zero. This makes it so that PIC and PIE module offsets come out looking like RVAs, but they're actually VAs. The difference between them simply happens to be zero. Reviewers: samsonov, majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11681 llvm-svn: 243895
* Re-commit r243686 - [Sanitizers] [Bug 24151] Generalize type of offset in ↵Daniel Sanders2015-07-311-1/+1
| | | | | | | | | internal_mmap The builder remains broken in the same way without this patch so this patch is innocent. llvm-svn: 243744
* Revert r243686 - [Sanitizers] [Bug 24151] Generalize type of offset in ↵Daniel Sanders2015-07-311-1/+1
| | | | | | | | | internal_mmap It's implicated in a buildbot failure and while the failure looks unrelated, this commit is the only probably candidate in the blamelist. llvm-svn: 243740
* [Sanitizers] [Bug 24151] Generalize type of offset in internal_mmapDaniel Sanders2015-07-301-1/+1
| | | | | | | | | | | | | | | | Summary: Using u64 as type for offset changes its value, changing starting address for map in file. This patch solves Bug 24151, which raises issue while mapping file in mips32. Patch by Mohit Bhakkad Reviewers: dsanders, kcc Subscribers: hans, llvm-commits, samsonov, nitesh.jain, sagar, bhushan, jaydeep Differential Revision: http://reviews.llvm.org/D11588 llvm-svn: 243686
* [sanitizer] Fix Mac build.Evgeniy Stepanov2015-07-281-1/+1
| | | | llvm-svn: 243480
* [asan] Read process name from /proc/self/cmdline on Linux.Evgeniy Stepanov2015-07-281-1/+3
| | | | | | | | | | Rename getBinaryBasename() to getProcessName() and, on Linux, read it from /proc/self/cmdline instead of /proc/self/exe. The former can be modified by the process. The main motivation is Android, where application processes re-write cmdline to a package name. This lets us setup per-application ASAN_OPTIONS through include=/some/path/%b. llvm-svn: 243473
* [sanitizer] Implement logging to syslog.Evgeniy Stepanov2015-07-231-3/+8
| | | | | | | | | | | | | | | | | Previously, Android target had a logic of duplicating all sanitizer output to logcat. This change extends it to all posix platforms via the use of syslog, controlled by log_to_syslog flag. Enabled by default on Android, off everywhere else. A bit of cmake magic is required to allow Printf() to call a libc function. I'm adding a stub implementation to support no-libc builds like dfsan and safestack. This is a second attempt. I believe I've fixed all the issues that prompted the revert: Mac build, and all kinds of non-CMake builds (there are 3 of those). llvm-svn: 243051
* Revert r242975.Evgeniy Stepanov2015-07-231-8/+3
| | | | | | Breaks Mac build. llvm-svn: 242978
* [sanitizer] Implement logging to syslog.Evgeniy Stepanov2015-07-221-3/+8
| | | | | | | | | | | | | Previously, Android target had a logic of duplicating all sanitizer output to logcat. This change extends it to all posix platforms via the use of syslog, controlled by log_to_syslog flag. Enabled by default on Android, off everywhere else. A bit of cmake magic is required to allow Printf() to call a libc function. I'm adding a stub implementation to support no-libc builds like dfsan and safestack. llvm-svn: 242975
* [Sanitizer] Teach ReadFileToBuffer to distinguish empty file from ↵Alexey Samsonov2015-07-171-4/+6
| | | | | | | | | | | | | | | | inaccessible file. Summary: This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=399 (sanitizers crash with empty suppression files). Reviewers: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11284 llvm-svn: 242594
* sanitizer_common: Only use _ReadWriteBarrier when targeting MSVC cl.exe.Peter Collingbourne2015-07-131-1/+1
| | | | | | Fixes check-ubsan when self hosting on Windows. llvm-svn: 242003
* sanitizer_common: Fix implementation of bit count operations on 64-bit Windows.Peter Collingbourne2015-07-131-11/+9
| | | | llvm-svn: 242002
* Add declaration of _ReadWriteBarrier. Fixes build of asan tests on Windows.Peter Collingbourne2015-07-021-0/+5
| | | | llvm-svn: 241227
* Re-apply r241217 with build fixes:Peter Collingbourne2015-07-021-3/+2
| | | | | | | - Disable building of the interceptor library on 64-bit Windows. - Mangle names in /alternatename directive for 32-bit Windows. llvm-svn: 241224
* Revert r241217, it breaks the build on Windows.Nico Weber2015-07-021-2/+3
| | | | llvm-svn: 241219
* ubsan: Port runtime library to (32- and 64-bit) Windows.Peter Collingbourne2015-07-021-3/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D10856 llvm-svn: 241217
* [asan] Fix SanitizerCommon.PthreadDestructorIterations test on Android L.Evgeniy Stepanov2015-06-291-9/+20
| | | | | | | 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
* [libsanitizer] Replace ReadBinaryName() with ReadBinaryNameCached(),Alexander Potapenko2015-06-291-0/+1
| | | | | | | | | which caches the executable name upon the first invocation. This is necessary because Google Chrome (and potentially other programs) restrict the access to /proc/self/exe on linux. This change should fix https://code.google.com/p/chromium/issues/detail?id=502974 llvm-svn: 240960
* [libsanitizer] Delete the unused GetBinaryName() function.Alexander Potapenko2015-06-261-1/+0
| | | | llvm-svn: 240767
OpenPOWER on IntegriCloud