summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[asan] On OS X, log reports to syslog and os_trace"Anna Zaks2015-10-271-34/+0
| | | | | | | | 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-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [sanitizer_common] Apply modernize-use-nullptr, other minor fixesVedant Kumar2015-09-301-11/+11
| | | | | | | | | | | | - Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13310 llvm-svn: 248964
* [Sanitizers] Make abort_on_error common flag.Alexey Samsonov2015-08-271-0/+2
| | | | | | | | | | | | | | Summary: Teach all sanitizers to call abort() instead of _exit() after printing an error report, if requested. This behavior is the default on Mac OS. Reviewers: kcc, kubabrecka Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12332 llvm-svn: 246205
* [Sanitizer] Use internal_memmove instead of the one implicitly generated by ↵Alexey Samsonov2015-08-271-2/+3
| | | | | | compiler. llvm-svn: 246198
* [Sanitizers] Allow to install several internal Die callbacks.Alexey Samsonov2015-08-241-9/+29
| | | | | | | | | | | | | | | | | 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-6/+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/+6
| | | | | | | 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
* [Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across ↵Alexey Samsonov2015-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | all sanitizers. Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 llvm-svn: 245734
* [windows] Fix deadlock on mmap failure due to CHECK recursionReid Kleckner2015-08-121-0/+17
| | | | | | | | | | | | | | | | | | | 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
* [Windows] Implement FileExists, ReadFromFile, and FindPathToBinaryReid Kleckner2015-08-101-0/+26
| | | | | | | | | | | | Summary: These are needed to talk to llvm-symbolizer on Windows. Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11920 llvm-svn: 244533
* [sanitizer] Fix Mac build.Evgeniy Stepanov2015-07-281-0/+11
| | | | llvm-svn: 243480
* [asan] Read process name from /proc/self/cmdline on Linux.Evgeniy Stepanov2015-07-281-5/+9
| | | | | | | | | | 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] Teach ReadFileToBuffer to distinguish empty file from ↵Alexey Samsonov2015-07-171-11/+11
| | | | | | | | | | | | | | | | 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
* [libsanitizer] Replace ReadBinaryName() with ReadBinaryNameCached(),Alexander Potapenko2015-06-291-1/+13
| | | | | | | | | 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-4/+0
| | | | llvm-svn: 240767
* [ASan] Add process basename to log name and error message toYury Gribov2015-06-051-1/+7
| | | | | | | | simplify analysis of sanitized systems logs. Differential Revision: http://reviews.llvm.org/D7333 llvm-svn: 239134
* [ASan] Make binary name reader cross-platform.Yury Gribov2015-06-041-0/+18
| | | | | | Differential Revision: http://reviews.llvm.org/D10213 llvm-svn: 239020
* [sanitizer_common] Added VS-style output for source locationsFilipe Cabecinhas2015-06-041-1/+2
| | | | | | | | | | | | | | | | | | | | | Summary: With this patch, we have a flag to toggle displaying source locations in the regular style: file:line:column or Visual Studio style: file(line,column) This way, they get picked up on the Visual Studio output window and one can double-click them to get to that file location. Reviewers: samsonov, rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10113 llvm-svn: 239000
* Use WriteToFile instead of internal_write in non-POSIX codeTimur Iskhodzhanov2015-04-091-2/+2
| | | | llvm-svn: 234487
* Use ReadFromFile instead of internal_read in non-POSIX codeTimur Iskhodzhanov2015-04-091-2/+2
| | | | llvm-svn: 234485
* Introduce CloseFile to be used instead of internal_close on non-POSIXTimur Iskhodzhanov2015-04-091-3/+3
| | | | llvm-svn: 234481
* [Sanitizers] Make OpenFile more portableTimur Iskhodzhanov2015-04-081-7/+5
| | | | llvm-svn: 234410
* [ASan] Unify handling of loaded modules between POSIX and WindowsTimur Iskhodzhanov2015-04-061-2/+3
| | | | | | Reviewed at http://reviews.llvm.org/D8805 llvm-svn: 234150
* [ASan/Win] Minor improvements towards enabling coverageTimur Iskhodzhanov2015-04-021-1/+8
| | | | llvm-svn: 233918
* [ASan] Distinguish between read, write and read-write file access modes in ↵Alexander Potapenko2015-03-231-2/+2
| | | | | | | | OpenFile. This is to fix mapping coverage files into memory on OSX. llvm-svn: 232936
* Improve SUMMARY reporting in sanitizers.Alexey Samsonov2015-03-171-8/+5
| | | | | | | | | Make sure SUMMARY is always reported unless print_summary flag is set to false, even if symbolizer is unavailable or report stack trace is empty. If file/line info for PC can't be evaluated, print module name/offset like we do in stack trace. llvm-svn: 232567
* [Sanitizer] Fix StripPathPrefix function and improve test case.Alexey Samsonov2015-03-021-6/+6
| | | | llvm-svn: 230986
* [Sanitizer] Print column number in SUMMARY line if it's available.Alexey Samsonov2015-02-271-6/+10
| | | | llvm-svn: 230721
* [Sanitizer] Move TemplateMatch() to sanitizer_common.cc. NFC.Alexey Samsonov2015-02-191-0/+42
| | | | llvm-svn: 229923
* [asan] Allow changing verbosity in activation flags.Evgeniy Stepanov2015-01-201-0/+2
| | | | | | | This change removes some debug output in asan_flags.cc that was reading the verbosity level before all the flags were parsed. llvm-svn: 226566
* [sanitizer] Additional error checking.Evgeniy Stepanov2015-01-161-3/+7
| | | | llvm-svn: 226279
* Fix memory leaks in GetListOfModules() users.Alexey Samsonov2015-01-081-0/+9
| | | | llvm-svn: 225472
* [Sanitizer] Remove the hardcoded limit of address ranges in LoadedModule.Alexey Samsonov2015-01-081-8/+9
| | | | | | This should fix https://code.google.com/p/address-sanitizer/issues/detail?id=368. llvm-svn: 225469
* [asan] introduce __sanitizer_set_death_callback, deprecate ↵Kostya Serebryany2014-12-151-6/+15
| | | | | | __asan_set_death_callback llvm-svn: 224286
* [Sanitizer] Don't modify mmap_limit_mb flag in runtime.Alexey Samsonov2014-12-111-6/+3
| | | | | | | Instead, rely on the fact that RAW_CHECK doesn't call mmap(), and we'll be able to print an error message and kill a program. llvm-svn: 224034
* [Sanitizer] Fix report_path functionality:Alexey Samsonov2014-12-111-34/+58
| | | | | | | | | | | | | | | | | | | | | | | Summary: - Make sure mmap() is never called inside RawWrite function. - Wrap a bunch of standalone globals in a ReportFile object. - Make sure accesses to these globals are thread-safe. - Fix report_path functionality on Windows, where __sanitizer_set_report_path() would break program. I've started this yak shaving in order to make "CommonFlags::mmap_limit_mb" immutable. Currently we drop this flag to zero before printing an error message. Test Plan: regression test suite Reviewers: kcc, glider Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6595 llvm-svn: 224031
* Replace InternalScopedBuffer<char> with InternalScopedString where applicable.Alexey Samsonov2014-12-021-8/+7
| | | | | | | | | | | | | | | | Summary: No functionality change. Test Plan: make check-all Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6472 llvm-svn: 223164
* Removed r221896, it seems to break build in various ways.Yury Gribov2014-11-131-20/+0
| | | | llvm-svn: 221912
* [ASan] Add process basename to log name and error message to simplify ↵Yury Gribov2014-11-131-0/+20
| | | | | | | | analysis of sanitized systems logs. Reviewed at http://reviews.llvm.org/D5724 llvm-svn: 221896
* [Sanitizer] Introduce generic stack frame rendering machineryAlexey Samsonov2014-11-051-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This commit introduces function __sanitizer::RenderFrame() that allows to render the contents of AddressInfo (essentially, symbolized stack frame) using the custom format string. This function can be used to implement stack frame formatting for both ThreadSanitizer and generic StackTrace::Print(), used in another places. This paves the way towards allowing user to control the format of stack frames, obtaining them in any format he desires, and/or enforcing the consistent output from all sanitizers. Test Plan: compiler-rt test suite Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6140 llvm-svn: 221409
* [Sanitizer] Get rid of unnecessary allocations in StripModuleName. NFC.Alexey Samsonov2014-11-041-11/+8
| | | | llvm-svn: 221287
* [Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().Alexey Samsonov2014-09-101-17/+0
| | | | | | | | | We may as well just use Symbolizer::GetOrInit() in all the cases. Don't call Symbolizer::Get() early in tools initialization: these days it doesn't do any important setup work, and we may as well create the symbolizer the first time it's actually needed. llvm-svn: 217558
* [asan] Exclude non-executable mappings from coverage.Evgeniy Stepanov2014-06-111-1/+2
| | | | llvm-svn: 210649
* [asancov] Write coverage directly to a memory-mapped file.Evgeniy Stepanov2014-05-271-12/+0
| | | | | | | | | | | This way does not require a __sanitizer_cov_dump() call. That's important on Android, where apps can be killed at arbitrary time. We write raw PCs to disk instead of module offsets; we also write memory layout to a separate file. This increases dump size by the factor of 2 on 64-bit systems. llvm-svn: 209653
* [sanitizer] Support sandboxing in sanitizer coverage.Sergey Matveev2014-05-191-3/+3
| | | | | | | | | | | Summary: Sandboxed code may now pass additional arguments to __sanitizer_sandbox_on_notify() to force all coverage data to be dumped to a single file (the default is one file per module). The user may supply a file or socket to write to. The latter option can be used to broker out the file writing functionality. If -1 is passed, we pre-open a file. llvm-svn: 209121
* tsan: stop background thread when sandbox is enabledDmitry Vyukov2014-04-241-0/+7
| | | | | | Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=56 llvm-svn: 207114
* [ASan] Replace a CHECK for mmap_limit_mb with a RAW_CHECK.Alexander Potapenko2014-04-151-1/+1
| | | | | | | In the case of a CHECK failure the program tries to fork and launch llvm-symbolizer, but hangs in mz_force_lock because one of the allocator locks is already acquired. llvm-svn: 206274
* [asan] try fixing the mmap_limit_mb failure on buildbot (tests pass locally)Kostya Serebryany2014-04-151-1/+2
| | | | llvm-svn: 206262
* [asan] added internal flag mmap_limit_mbKostya Serebryany2014-04-141-0/+18
| | | | llvm-svn: 206178
OpenPOWER on IntegriCloud