summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common.cc
AgeCommit message (Collapse)Author
2015-08-22[Sanitizer] Dump coverage if we're killing the program with __sanitizer::Die().Alexey Samsonov
Previously we had to call __sanitizer_cov_dump() from tool-specific callbacks - instead, let sanitizer_common library handle this in a single place. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245770 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across ↵Alexey Samsonov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245734 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-12[windows] Fix deadlock on mmap failure due to CHECK recursionReid Kleckner
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244840 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-10[Windows] Implement FileExists, ReadFromFile, and FindPathToBinaryReid Kleckner
Summary: These are needed to talk to llvm-symbolizer on Windows. Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11920 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244533 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28[sanitizer] Fix Mac build.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243480 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28[asan] Read process name from /proc/self/cmdline on Linux.Evgeniy Stepanov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243473 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-17[Sanitizer] Teach ReadFileToBuffer to distinguish empty file from ↵Alexey Samsonov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242594 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-29[libsanitizer] Replace ReadBinaryName() with ReadBinaryNameCached(),Alexander Potapenko
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240960 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-26[libsanitizer] Delete the unused GetBinaryName() function.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240767 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-05[ASan] Add process basename to log name and error message toYury Gribov
simplify analysis of sanitized systems logs. Differential Revision: http://reviews.llvm.org/D7333 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@239134 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04[ASan] Make binary name reader cross-platform.Yury Gribov
Differential Revision: http://reviews.llvm.org/D10213 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@239020 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04[sanitizer_common] Added VS-style output for source locationsFilipe Cabecinhas
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@239000 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use WriteToFile instead of internal_write in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234487 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use ReadFromFile instead of internal_read in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Introduce CloseFile to be used instead of internal_close on non-POSIXTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234481 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08[Sanitizers] Make OpenFile more portableTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234410 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06[ASan] Unify handling of loaded modules between POSIX and WindowsTimur Iskhodzhanov
Reviewed at http://reviews.llvm.org/D8805 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234150 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-02[ASan/Win] Minor improvements towards enabling coverageTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@233918 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23[ASan] Distinguish between read, write and read-write file access modes in ↵Alexander Potapenko
OpenFile. This is to fix mapping coverage files into memory on OSX. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232936 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17Improve SUMMARY reporting in sanitizers.Alexey Samsonov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232567 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02[Sanitizer] Fix StripPathPrefix function and improve test case.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230986 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27[Sanitizer] Print column number in SUMMARY line if it's available.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230721 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-19[Sanitizer] Move TemplateMatch() to sanitizer_common.cc. NFC.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229923 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20[asan] Allow changing verbosity in activation flags.Evgeniy Stepanov
This change removes some debug output in asan_flags.cc that was reading the verbosity level before all the flags were parsed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226566 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16[sanitizer] Additional error checking.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226279 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-08Fix memory leaks in GetListOfModules() users.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225472 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-08[Sanitizer] Remove the hardcoded limit of address ranges in LoadedModule.Alexey Samsonov
This should fix https://code.google.com/p/address-sanitizer/issues/detail?id=368. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225469 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15[asan] introduce __sanitizer_set_death_callback, deprecate ↵Kostya Serebryany
__asan_set_death_callback git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224286 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11[Sanitizer] Don't modify mmap_limit_mb flag in runtime.Alexey Samsonov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224034 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11[Sanitizer] Fix report_path functionality:Alexey Samsonov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224031 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-02Replace InternalScopedBuffer<char> with InternalScopedString where applicable.Alexey Samsonov
Summary: No functionality change. Test Plan: make check-all Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6472 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223164 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13Removed r221896, it seems to break build in various ways.Yury Gribov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221912 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13[ASan] Add process basename to log name and error message to simplify ↵Yury Gribov
analysis of sanitized systems logs. Reviewed at http://reviews.llvm.org/D5724 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221896 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-05[Sanitizer] Introduce generic stack frame rendering machineryAlexey Samsonov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221409 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-04[Sanitizer] Get rid of unnecessary allocations in StripModuleName. NFC.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221287 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10[Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().Alexey Samsonov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11[asan] Exclude non-executable mappings from coverage.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210649 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-27[asancov] Write coverage directly to a memory-mapped file.Evgeniy Stepanov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209653 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-19[sanitizer] Support sandboxing in sanitizer coverage.Sergey Matveev
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209121 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-24tsan: stop background thread when sandbox is enabledDmitry Vyukov
Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=56 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207114 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15[ASan] Replace a CHECK for mmap_limit_mb with a RAW_CHECK.Alexander Potapenko
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206274 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15[asan] try fixing the mmap_limit_mb failure on buildbot (tests pass locally)Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206262 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-14[asan] added internal flag mmap_limit_mbKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206178 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26Reapply r201910. MSVC gets __func__ defined explicitly, even though itJoerg Sonnenberger
can't build anything here. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202297 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-22Revert "Replace __FUNCTION__ with __func__, the latter being standard ↵Reid Kleckner
C99/C++11." This reverts commit r201910. While __func__ may be standard in C++11, it was only recently added to MSVC in 2013 CTP, and LLVM supports MSVC 2012. __FUNCTION__ may not be standard, but it's *very* portable. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201916 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-21Replace __FUNCTION__ with __func__, the latter being standard C99/C++11.Joerg Sonnenberger
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201910 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[Sanitizer] Replace Symbolizer::IsAvailable and ↵Alexey Samsonov
Symbolizer::IsExternalAvailable with Symbolizer::CanReturnFileLineInfo. Remove now redundant checks in symbolizer initialization in TSan and MSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198000 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18[Sanitizers] Rename Symbolizer::SymbolizeCode to Symbolizer::SymbolizePCTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197569 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-04[sanitizer] Fix log_path behavior with StopTheWorld.Sergey Matveev
Summary: Fix race on report_fd/report_fd_pid between the parent process and the tracer task. Reviewers: samsonov Reviewed By: samsonov CC: llvm-commits, kcc, dvyukov Differential Revision: http://llvm-reviews.chandlerc.com/D2306 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196385 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-15Reapply asan coverage changes 194702-194704.Bob Wilson
I still don't know what is causing our bootstrapped LTO buildbots to fail, but llvm r194701 seems to be OK and I can't imagine that these changes could cause the problem. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194790 91177308-0d34-0410-b5e6-96231b3b80d8