summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/ubsan
Commit message (Collapse)AuthorAgeFilesLines
...
* Add missing " at the end of the #error directive.Alexey Samsonov2015-04-021-1/+1
| | | | llvm-svn: 233879
* [CMake] Fixup for r233861: don't build standalone UBSan on unsupported ↵Alexey Samsonov2015-04-011-25/+27
| | | | | | platforms. llvm-svn: 233865
* [UBSan] Embed UBSan into ASan runtime (compiler-rt part).Alexey Samsonov2015-04-019-88/+143
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Change the way we use ASan and UBSan together. Instead of keeping two separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on a platform, all UBSan sources are just compiled into dummy empty object files. UBSan initialization code (e.g. flag parsing) is directly called from ASan initialization, so we are able to enforce correct initialization order. This mirrors the approach we already use for ASan+LSan. This change doesn't modify the way we use standalone UBSan. Test Plan: regression test suite Reviewers: kubabrecka, zaks.anna, rsmith, kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8646 llvm-svn: 233861
* [PPC64]This activates UBSan for the power architecture.Bill Seurer2015-04-012-2/+8
| | | | | | | | One test case is updated to allow for differences between power and other architectures in behavior when returning from main in certain instances http://reviews.llvm.org/D8743 llvm-svn: 233813
* [UBSan] Explicitly list all supported OS/arch pairs supported by UBSan.Alexey Samsonov2015-03-269-7/+54
| | | | llvm-svn: 233295
* Revert "Revert "[UBSan] Use shared library for UBSan on OS X" and its followup"Alexey Samsonov2015-03-241-7/+14
| | | | | | Fix the build/tests by providing -lc++abi for UBSan runtime only. llvm-svn: 233122
* Revert "[UBSan] Use shared library for UBSan on OS X" and its followupJustin Bogner2015-03-241-13/+7
| | | | | | | | | | This change caused test failures on darwin, and the followup which was meant to fix those caused compiler-rt to start failing to link. Reverting to get the build working again. This reverts r233071 and r233036. llvm-svn: 233097
* [UBSan] Use shared library for UBSan on OS X (compiler-rt part).Alexey Samsonov2015-03-231-7/+13
| | | | | | | | | | | | | | | | Summary: Switch to shared library for UBSan. Add support for building UBSan on OSX and iossim by cargo-culting ASan build rules. Test Plan: regression test suite Reviewers: zaks.anna, kubabrecka Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8473 llvm-svn: 233036
* [UBSan] Introduce "ubsan_standalone" library (compiler-rt part).Alexey Samsonov2015-03-231-7/+27
| | | | | | | | | | | | Get rid of "libclang_rt.san" library that used to contain sanitizer_common pieces required by UBSan if it's used in a standalone mode. Instead, build two variants of UBSan runtime: "ubsan" and "ubsan_standalone" (same for "ubsan_cxx" and "ubsan_standalone_cxx"). Later "ubsan" and "ubsan_cxx" libraries will go away, as they will embedded it into corresponding ASan runtimes. llvm-svn: 233011
* [Sanitizer] Print column number in SUMMARY line if it's available.Alexey Samsonov2015-02-271-2/+7
| | | | llvm-svn: 230721
* [CMake] Make sure we built one variant of i386/i686 runtime libraries.Alexey Samsonov2015-02-261-1/+1
| | | | llvm-svn: 230683
* [Sanitizer] Refactor SuppressionContext class.Alexey Samsonov2015-02-205-9/+24
| | | | | | | | | | | | | | 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. llvm-svn: 230026
* Revert "Remove support for building sanitizers from Makefile/autoconf build."Matthias Braun2015-02-171-0/+26
| | | | | | | | | This reverts commit r229556. Reverting this for now as internal apple builds rely on this functionality. llvm-svn: 229585
* Remove support for building sanitizers from Makefile/autoconf build.Alexey Samsonov2015-02-171-26/+0
| | | | | | | | They autotools build has a number of missing features, supports less OS, architectures, build configurations, doesn't have any tests and is hard to support in sync with CMake build. llvm-svn: 229556
* [UBSan] Allow UBSan location to store frames returned by symbolizer.Alexey Samsonov2015-02-113-72/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 228869
* Revert "[UBSan] Enable -Wglobal-constructors."Justin Bogner2015-02-111-5/+0
| | | | | | | | | We're still using global constructors when not on linux, so this was causing warnings on Darwin. Reverting for now. This reverts r228384. llvm-svn: 228795
* [UBSan] Add report deduplication for -fsanitize=function.Alexey Samsonov2015-02-111-6/+9
| | | | | | | | | | | | | | | | | | Summary: Make sure we don't print the error report from -fsanitize=function twice for the same source location, as we do in another UBSan handlers. Test Plan: check-ubsan test suite Reviewers: rsmith, pcc Reviewed By: pcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7524 llvm-svn: 228772
* [UBSan] Reduce the number of getCallerLocation() calls.Alexey Samsonov2015-02-103-15/+14
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 228732
* [UBSan] Enable -Wglobal-constructors.Yury Gribov2015-02-061-0/+5
| | | | llvm-svn: 228384
* [asan] Allow changing verbosity in activation flags.Evgeniy Stepanov2015-01-201-0/+1
| | | | | | | 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] Flag parser rewrite.Evgeniy Stepanov2015-01-153-23/+33
| | | | | | | The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. llvm-svn: 226169
* [Sanitizer] Change the runtime flag representation.Alexey Samsonov2015-01-073-14/+44
| | | | | | | | | | | This mirrors r225239 to all the rest sanitizers: ASan, DFSan, LSan, MSan, TSan, UBSan. Now the runtime flag type, name, default value and description is located in the single place in the .inc file. llvm-svn: 225327
* [ubsan] partially enable -fsanitize-coverage=N with ubsan. It will work as ↵Kostya Serebryany2015-01-061-0/+1
| | | | | | usual in most cases but will not dump coverage on error with -fno-sanitize-recover (that'll be a separate fix) llvm-svn: 225234
* Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after ↵Alexey Samsonov2015-01-021-2/+4
| | | | | | | | | | | | | | | | initialization."" Fix test failures by introducing CommonFlags::CopyFrom() to make sure compiler doesn't insert memcpy() calls into runtime code. Original commit message: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. llvm-svn: 225088
* Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization."Chandler Carruth2015-01-021-3/+2
| | | | | | | | | | We've got some internal users that either aren't compatible with this or have found a bug with it. Either way, this is an isolated cleanup and so I'm reverting it to un-block folks while we investigate. Alexey and I will be working on fixing everything up so this can be re-committed soon. Sorry for the noise and any inconvenience. llvm-svn: 225079
* Revert "UBSan: Teach isDerivedFromAtOffset and findBaseAtOffset about vbases"Alexey Samsonov2014-12-301-26/+21
| | | | | | | | This reverts commit r221445. This change leads to false positives reports from -fsanitize=vptr. See original commit thread for more details. llvm-svn: 224972
* [Sanitizer] Make CommonFlags immutable after initialization.Alexey Samsonov2014-12-221-2/+3
| | | | | | | | | | | | | | | | | | | Summary: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. Test Plan: regression test suite Reviewers: kcc, eugenis, glider Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6741 llvm-svn: 224736
* [Sanitizer] Refactor CommonFlags interface. NFC.Alexey Samsonov2014-12-191-3/+3
| | | | | | | | | | Add CommonFlags::SetDefaults() and CommonFlags::ParseFromString(), so that this object can be easily tested. Enforce that ParseCommonFlagsFromString() and SetCommonFlagsDefaults() work only with singleton CommonFlags, shared across all sanitizer runtimes. llvm-svn: 224617
* Simplify Symbolizer::SymbolizePC() interface.Alexey Samsonov2014-12-021-7/+15
| | | | | | | | | | | 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. llvm-svn: 223145
* UBSan: Teach isDerivedFromAtOffset and findBaseAtOffset about vbasesDavid Majnemer2014-11-061-21/+26
| | | | | | | | | | | | When the __virtual_mask is set, __offset_flags >> __offset_shift yields an offset into the vtable. Dereferencing this vtable slot gets us the vbase offset. Adjust a test case to verify that this, in fact, works. Differential Revision: http://reviews.llvm.org/D6074 llvm-svn: 221445
* [Sanitizer] Introduce generic stack frame rendering machineryAlexey Samsonov2014-11-051-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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] Make StackTrace a lightweight reference to array of PCs, andAlexey Samsonov2014-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | introduce a BufferedStackTrace class, which owns this array. Summary: This change splits __sanitizer::StackTrace class into a lightweight __sanitizer::StackTrace, which doesn't own array of PCs, and BufferedStackTrace, which owns it. This would allow us to simplify the interface of StackDepot, and eventually merge __sanitizer::StackTrace with __tsan::StackTrace. Test Plan: regression test suite. Reviewers: kcc, dvyukov Reviewed By: dvyukov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5985 llvm-svn: 220635
* Sanitize upcasts and conversion to virtual base.Alexey Samsonov2014-10-131-3/+3
| | | | | | | | | | | This change adds UBSan check to upcasts. Namely, when we perform derived-to-base conversion, we: 1) check that the pointer-to-derived has suitable alignment and underlying storage, if this pointer is non-null. 2) if vptr-sanitizer is enabled, and we perform conversion to virtual base, we check that pointer-to-derived has a matching vptr. llvm-svn: 219642
* [sanitizer] Add i686 arch to compiler-rt.Evgeniy Stepanov2014-10-011-1/+1
| | | | | | | | | | This is needed so we can produce -i686- named libraries for x86 Android (which is i686-linux-android). An alternative solution would be keeping the "i386" name internally and tweaking the OUTPUT_NAME of compiler-rt libraries. llvm-svn: 218761
* UBSan: print 'undefined-behavior' instead of 'runtime-error' in report summaryAlexey Samsonov2014-09-221-3/+3
| | | | llvm-svn: 218264
* [UBSan] Introduce more flexible __ubsan_default_options function instead of ↵Alexey Samsonov2014-09-192-13/+22
| | | | | | UBSAN_DEFAULT_OPTIONS compile definition llvm-svn: 218137
* [UBSan] Optionally report summary in UBSan error reports.Alexey Samsonov2014-09-194-20/+40
| | | | | | | 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). llvm-svn: 218135
* PR20721: Don't let UBSan print inaccessible memoryAlexey Samsonov2014-09-171-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: UBSan needs to check if memory snippet it's going to print resides in addressable memory. Similar check might be helpful in ASan with dump_instruction_bytes option (see http://reviews.llvm.org/D5167). Instead of scanning /proc/self/maps manually, delegate this check to the OS kernel: try to write this memory in a syscall and assume that memory is inaccessible if the syscall failed (e.g. with EFAULT). Fixes PR20721. Test Plan: compiler-rt test suite Reviewers: eugenis, glider Reviewed By: glider Subscribers: emaste, ygribov, llvm-commits, glider, rsmith Differential Revision: http://reviews.llvm.org/D5253 llvm-svn: 217971
* [UBSan] Don't overflow when calculating memory range that should be dumpedAlexey Samsonov2014-09-121-6/+16
| | | | llvm-svn: 217703
* Revert r217616. Problems and complexity it introduces negate its benefitAlexey Samsonov2014-09-123-3/+9
| | | | llvm-svn: 217652
* [UBSan] Parse common flags from UBSAN_OPTIONS runtime variable even ifAlexey Samsonov2014-09-113-9/+3
| | | | | | UBSan is combined with ASan. llvm-svn: 217616
* [Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().Alexey Samsonov2014-09-102-3/+2
| | | | | | | | | 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
* [UBSan] Add noinline attribute to handlers that should never return.Alexey Samsonov2014-09-102-15/+48
| | | | | | | | | | | | | FIx a problem reported by Jakub Jelinek: don't do early-exit from fatal UBSan handlers: even if source location is disabled (i.e. acquired by some other thread), we should continue the execution to make sure that: a) some thread will print the error report before calling Die(). b) handler marked as noreturn will indeed not return. Explicitly add "Die()" calls at the end of all fatal handlers to be sure UBSan handlers don't introduce UB themselves. llvm-svn: 217542
* [UBSan] Add halt_on_error runtime flagAlexey Samsonov2014-09-103-1/+5
| | | | llvm-svn: 217535
* Remove extra semicolon [-Wpedantic]Alexey Samsonov2014-09-081-1/+1
| | | | llvm-svn: 217407
* Report source location of returns_nonnull attribute in UBSan reports.Alexey Samsonov2014-09-082-0/+3
| | | | llvm-svn: 217400
* Revert accidental changeAlexey Samsonov2014-09-081-2/+2
| | | | llvm-svn: 217391
* Implement nonnull-attribute sanitizerAlexey Samsonov2014-09-083-5/+37
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements a new UBSan check, which verifies that function arguments declared to be nonnull with __attribute__((nonnull)) are actually nonnull in runtime. To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs (where applicable) and if function declaration has nonnull attribute specified for a certain formal parameter, we compare the corresponding RValue to null as soon as it's calculated. Test Plan: regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, rnk Differential Revision: http://reviews.llvm.org/D5082 llvm-svn: 217389
* [UBSan] Add support for printing backtraces to all UBSan handlersAlexey Samsonov2014-08-225-68/+102
| | | | llvm-svn: 216289
* [UBSan] Add returns-nonnull sanitizer.Alexey Samsonov2014-08-132-0/+26
| | | | | | | | | | | | | | | | | | | | Summary: This patch adds a runtime check verifying that functions annotated with "returns_nonnull" attribute do in fact return nonnull pointers. It is based on suggestion by Jakub Jelinek: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140623/223693.html. Test Plan: regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4849 llvm-svn: 215485
OpenPOWER on IntegriCloud