summaryrefslogtreecommitdiff
path: root/lib/ubsan/ubsan_diag.h
AgeCommit message (Collapse)Author
2017-11-09[sanitizers] Rename GetStackTraceWithPcBpAndContextVitaly Buka
Name does not need to enumerate arguments. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317774 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-15[ubsan] Extract GetStackTraceWithPcBpAndContext similar to asan versionVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313350 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18[UBSan] Implement runtime suppressions (PR25066).Alexey Samsonov
Summary: Add the ability to suppress UBSan reports for files/functions/modules at runtime. The user can now pass UBSAN_OPTIONS=suppressions=supp.txt with the contents of the form: signed-integer-overflow:file-with-known-overflow.cpp alignment:function_doing_unaligned_access vptr:shared_object_with_vptr_failures.so Suppression categories match the arguments passed to -fsanitize= flag (although, see below). There is no overhead if suppressions are not provided. Otherwise there is extra overhead for symbolization. Limitations: 1) sometimes suppressions need debug info / symbol table to function properly (although sometimes frontend generates enough info to do the match). 2) it's only possible to suppress recoverable UB kinds - if you've built the code with -fno-sanitize-recover=undefined, suppressions will not work. 3) categories are fine-grained check kinds, not groups like "undefined" or "integer", so you can't write "undefined:file_with_ub.cc". Reviewers: rsmith, kcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15363 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256018 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09[UBSan] Clarify the way we disable de-duplication of reports from ↵Alexey Samsonov
unrecoverable handlers. Let unrecoverable handlers be responsbile for killing the program with Die(), and let functions which print the error report know if it's going to happen. Re-write the comments to describe the situation. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255081 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-08[UBSan] Remove "-fsanitize=" prefix from ubsan_checks.inc. NFC.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255075 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-08[UBSan] Always calculate ErrorType (kind of UB) before printing a report.Alexey Samsonov
Currently, this is an NFC. However, knowing out the kind of error report before we bring up all the reporting machinery (implemented in ScopedReport class) is important once we teach UBSan runtime suppressions. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255074 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-30Revert "Apply modernize-use-default to compiler-rt."Alexey Samsonov
This reverts commit r250823. Replacing at least some of empty constructors with "= default" variants is a semantical change which we don't want. E.g. __tsan::ClockBlock contains a union of large arrays, and it's critical for correctness and performance that we don't memset() these arrays in the constructor. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251717 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-20Apply modernize-use-default to compiler-rt.Angel Garcia Gomez
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: klimek, bkramer Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13892 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@250823 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24[UBSan] Add the ability to print more precise error kind in summary line.Alexey Samsonov
Reviewers: rsmith, pcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D12215 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245897 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08CFI: Get check-cfi passing on Windows.Peter Collingbourne
Specifically: - Start using %expect_crash. - Provide an implementation of __ubsan::getDynamicTypeInfoFromVtable for the Microsoft C++ ABI. This is all that is needed for CFI diagnostics; UBSan's -fsanitize=vptr also requires an implementation of __ubsan::checkDynamicType. - Build the sanitizer runtimes against the release version of the C runtime, even in debug builds. - Accommodate demangling differences in tests. Differential Revision: http://reviews.llvm.org/D11029 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241745 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-20[Sanitizer] Refactor SuppressionContext class.Alexey Samsonov
SuppressionContext is no longer a singleton, shared by all sanitizers, but a regular class. Each of ASan, LSan, UBSan and TSan now have their own SuppressionContext, which only parses suppressions specific to that sanitizer. "suppressions" flag is moved away from common flags into tool-specific flags, so the user now may pass ASAN_OPTIONS=suppressions=asan_supp.txt LSAN_OPIONS=suppressions=lsan_supp.txt in a single invocation. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230026 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11[UBSan] Allow UBSan location to store frames returned by symbolizer.Alexey Samsonov
Summary: __ubsan::getFunctionLocation() used to issue a call to symbolizer, and convert the result (SymbolizedStack) to one of UBSan structures: SourceLocation, ModuleLocation or MemoryLocation. This: (1) is inefficient: we do an extra allocation/deallocation to copy data, while we can instead can just pass SymbolizedStack around (which contains all the necessary data). (2) leaks memory: strings stored in SourceLocation/MemoryLocation are never deallocated, and Filipe Cabecinhas suggests this causes crashes of UBSan-ified programs in the wild. Instead, let Location store a pointer to SymbolizedStack object, and make sure it's properly deallocated when UBSan handler exits. ModuleLocation is made obsolete by this change, and is deleted. Test Plan: check-ubsan test suite Reviewers: rsmith, filcab Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7548 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228869 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10[UBSan] Reduce the number of getCallerLocation() calls.Alexey Samsonov
getCallerLocation() is expensive as it issues a call to symbolizer. (In fact, this function has a memory leak at the moment, but this will be fixed in the nearest future). We should only call it if we're actually going to print an error report, in particular, once for every reported source location. __ubsan_handle_type_mismatch: call getCallerLocation() only if provided source location is invalid, and only if the report is not deduplicated. __ubsan_handle_float_cast_overflow: call getSourceLocation with correct CallerPC (the one in user code, not in UBSan handler). Source location for this check is not currently emitted by frontend. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228732 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-19[UBSan] Optionally report summary in UBSan error reports.Alexey Samsonov
By default summary is not printed if UBSan is run in a standalone mode, but is printed if it's combined with another sanitizer (like ASan). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@218135 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22[UBSan] Add support for printing backtraces to all UBSan handlersAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216289 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-05[UBSan] Allow to suppress reports from vptr checker for specified types.Alexey Samsonov
Based on http://reviews.llvm.org/D4702 by Byoungyoung Lee! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214833 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-30[UBSan] Introduce ScopedReport object.Alexey Samsonov
This object is used to encapsulate all actions that need to be done before/after printing UBSan diagnostics. Currently these actions are: * locking a mutex to ensure that UBSan diagnostics from several threads won't mix with each other and with other sanitizers' reports * killing a program once the report is printed (if necessary). Use this object in all UBSan handlers. Unify the way we implement fatal and non-fatal handlers by making all the handlers simple one-liners that redirect __ubsan_handle_foo(_abort)? to handleFooImpl(). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214279 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29[UBSan] Get pc/bp for stack unwinding as early as possible.Alexey Samsonov
This will ensure that stack frames in error reports will not contain internal UBSan failures, and frame #0 will be the actual place in the program where the error happens. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214245 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23Fix unused-variable warningAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213786 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23[UBSan] Add the ability to dump call stacks to -fsanitize=vptrAlexey Samsonov
This change introduces the first UBSan-specific runtime flag: print_stacktrace (off by default). It can be set in UBSAN_OPTIONS to unwind and print call stacks in addition to diagnostic messages. For now these stacks are printed only in vptr checker. This change is based on http://reviews.llvm.org/D4410 by Byoungyoung Lee! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213783 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-20Runtime support for the indirect function call checker.Peter Collingbourne
Differential Revision: http://llvm-reviews.chandlerc.com/D1339 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193060 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18ubsan: Demangle class names, and be more informative when a reinterpret_castRichard Smith
has got us to the wrong offset within an object. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170423 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18ubsan: When diagnosing something wrong somewhere in memory, emit a noteRichard Smith
pointing at the bad location and a snippet of nearby memory values. This is strictly best-effort; reading these bytes to display the note could lead to a seg fault, and that's explicitly OK. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170415 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18ubsan: if the frontend didn't provide us with a source location, try to workRichard Smith
one out from the return address. Currently, we can only resolve this address to a file and line number if we have an external symbolizer. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170407 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12-fcatch-undefined-behavior: Runtime library support for trapping conversions ↵Richard Smith
to or from a floating-point type where the source value is not in the range of representable values of the destination type. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165844 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-09Add a runtime diagnostics library for Clang's -fcatch-undefined-behavior.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165533 91177308-0d34-0410-b5e6-96231b3b80d8