summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common_libcdep.cc
AgeCommit message (Collapse)Author
2017-11-10[sanitizer] Remove references and hide CommonSanitizerReportMutexVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317865 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-23[ubsan] Replace CommonSanitizerReportMutex with ScopedErrorReportLockVitaly Buka
Reviewers: eugenis, alekseyshl Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D38194 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314053 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22[lsan] Deadly signal handler for lsanVitaly Buka
Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: llvm-commits, dberris, kubamracek, krytarowski Differential Revision: https://reviews.llvm.org/D37608 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314041 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22[sanitizer] Replace thread id with GetThreadSelfVitaly Buka
This allows to avoid constructor parameter git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314040 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22[sanitizer] Move ScopedErrorReportLock into libcdep versionVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314039 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-19[sanitizer] Don't define common ReportDeadlySignal on FuchsiaPetr Hosek
This causes a linker error because of duplicate symbol since ReportDeadlySignal is defined both in sanitizer_common_libcdep and sanitizer_fuchsia. Differential Revision: https://reviews.llvm.org/D37952 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313641 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18[sanitizer] Move StartReportDeadlySignal into sanitizer_common_libcdepVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313518 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-14[sanitizer] Move stack overflow and signal reporting from Asan into common.Vitaly Buka
Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D37844 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313310 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-13[compiler-rt] Compile signal specific functions only for !SANITIZER_GOVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313130 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-13[compiler-rt] Move dump_instruction_bytes and dump_registers into ↵Vitaly Buka
sanitizer_common Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D37766 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313117 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-01[sanitizer_common] Disable filesystem-related code for FuchsiaVitaly Buka
Summary: Fuchsia doesn't support filesystem access per se at low level. So it won't use any of the filesystem-oriented code in sanitizer_common. Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: vitalybuka Subscribers: kubamracek, phosek, filcab, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36029 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309749 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-22[sanitizer_common] Move filesystem-related code out of sanitizer_common.ccVitaly Buka
Summary: This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Submitted on behalf of Roland McGrath. Reviewers: kcc, eugenis, alekseyshl Reviewed By: alekseyshl Subscribers: vitalybuka, llvm-commits, kubamracek, mgorny, phosek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35591 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308819 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20Revert "[sanitizer_common] Move filesystem-related code out of ↵Vitaly Buka
sanitizer_common.cc" Breaks Windows build. This reverts commit r308640. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308648 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20[sanitizer_common] Move filesystem-related code out of sanitizer_common.ccAlex Shlyapnikov
This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Commiting for mcgrathr. Reviewers: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35591 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308640 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14[ubsan] Use the correct tool name in diagnosticsVedant Kumar
When using ASan and UBSan together, the common sanitizer tool name is set to "AddressSanitizer". That means that when a UBSan diagnostic is printed out, it looks like this: SUMMARY: AddressSanitizer: ... This can confuse users. Fix it so that we always use the correct tool name when printing out UBSan diagnostics. Differential Revision: https://reviews.llvm.org/D32066 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300358 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-15[asan] add one more argument to __sanitizer_print_memory_profile, remove a ↵Kostya Serebryany
redundant weak definition. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297914 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31[sanitizer] Define as weak, functions that are declared as weak.Marcos Pividori
Differential Revision: https://reviews.llvm.org/D29228 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293681 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29Return memory to OS right after free (not in the async thread).Evgeniy Stepanov
Summary: In order to avoid starting a separate thread to return unused memory to the system (the thread interferes with process startup on Android, Zygota waits for all threads to exit before fork, but this thread never exits), try to return it right after free. Reviewers: eugenis Subscribers: cryptoad, filcab, danalbert, kubabrecka, llvm-commits Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27003 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288091 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28tsan: fix windows buildDmitry Vyukov
Currently fails with: C:\workdir\compiler-rt\lib\tsan\go>gcc -c -o race_windows_amd64.syso gotsan.cc -I..\rtl -I..\.. -I..\..\sanitizer_common -I..\..\..\include -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -Wno-error=at tributes -Wno-attributes -Wno-format -Wno-maybe-uninitialized -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer -std=c++11 gotsan.cc:9229:0: warning: ignoring #pragma comment [-Wunknown-pragmas] #pragma comment(linker, "/alternatename:__sanitizer_print_memory_profile=__sanitizer_default_print_memory_profile") // NOLINT ^ gotsan.cc: In function 'void __sanitizer_print_memory_profile(int)': gotsan.cc:9226:17: error: redefinition of 'void __sanitizer_print_memory_profile(int)' extern "C" void __sanitizer_print_memory_profile(int top_percent) {} ^ gotsan.cc:6898:6: note: 'void __sanitizer_print_memory_profile(int)' previously defined here void __sanitizer_print_memory_profile(int top_percent) { Remove __sanitizer_print_memory_profile from Go build, it is not needed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@285400 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15[compiler-rt] Do not introduce __sanitizer namespace globallyAnna Zaks
The definitions in sanitizer_common may conflict with definitions from system headers because: The runtime includes the system headers after the project headers (as per LLVM coding guidelines). lib/sanitizer_common/sanitizer_internal_defs.h pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with: using namespace __sanitizer; // NOLINT This patch solves the problem by introducing the namespace only within the sanitizer namespaces as proposed by Dmitry. Differential Revision: https://reviews.llvm.org/D21947 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281657 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15[sanitizer] one more attempt to fix things with ↵Kostya Serebryany
__sanitizer_print_memory_profile git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281574 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-14[tsan] fix tsan build by adding a dummy __sanitizer_print_memory_profileKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281553 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-14[asan] add heap_profile=1 to asan to periodically print the heap profile. So ↵Kostya Serebryany
far this is a very basic heap-profile functionality git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281546 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-12[asan] Cleanup: Move tid into ErrorBase, add const to BufferedStackTrace, be ↵Filipe Cabecinhas
consistent in constructor arguments and member order. Summary: As mentioned in D24394, I'm moving tid to ErrorBase, since basically all errors need it. Also mentioned in the same review are other cleanups like adding const to BufferedStackTrace and make sure constructor orders are consistent. Reviewers: vitalybuka, kcc, eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D24455 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281236 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-26[asan] first attempt at releasing free-d memory back to the system using ↵Kostya Serebryany
madvise. Requires quite some tuning. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279887 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-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-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
2015-04-08[Sanitizer RT] Get rid of internal_isattyTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234423 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08Move some POSIX-specific functions from sanitizer_libc.h to a new ↵Timur Iskhodzhanov
sanitizer_posix.h git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234418 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-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-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-17Silence an MSVC warning about testing a function for truth without calling itReid Kleckner
In general, this is a reasonable warning, except real_pthread_create is weak and can be null. The existing usage is correct as it the function is declared with SANITIZER_WEAK, but MSVC can't know that because it is defined to nothing on Windows. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229562 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-06[asan] add a flag soft_rss_limit_mbKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225323 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16[asan] new flag: hard_rss_limit_mbKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224353 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-02Simplify Symbolizer::SymbolizePC() interface.Alexey Samsonov
Return a linked list of AddressInfo objects, instead of using an array of these objects as an output parameter. This simplifies the code in callers of this function (especially TSan). Fix a few memory leaks from internal allocator, when the returned AddressInfo objects were not properly cleared. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223145 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-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-02-26[sanitizer] Add a flag to enable/disable report colorization.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202249 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03[lsan] Colorize LSan reports.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189804 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-29Fix MSVC W3 compiler warningsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182857 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-17[nolibc] Begin moving sanitizer_common's libc-dependent code to a separate ↵Peter Collingbourne
library Introduce a new object library, RTSanitizerCommonLibc, which will contain the subset of sanitizer_common with libc dependencies. RTSanitizerCommon contains the remainder of sanitizer_common, and is intended to have no libc dependencies. Begin moving code to RTSanitizerCommonLibc, starting with sanitizer_common.cc, whose libc-dependent portion is moved to sanitizer_common_libcdep.cc, the first member of the new library. This split affects the CMake build only. The makefile build continues to produce the full sanitizer_common library. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182118 91177308-0d34-0410-b5e6-96231b3b80d8