diff options
| author | Alexey Samsonov <vonosmas@gmail.com> | 2015-12-18 19:56:42 +0000 |
|---|---|---|
| committer | Alexey Samsonov <vonosmas@gmail.com> | 2015-12-18 19:56:42 +0000 |
| commit | 081a24e3a7cf26c5190699ea8567786c9cb01797 (patch) | |
| tree | 95d1e305127ae178aac4591a8cd36ce418210f1c /compiler-rt/test/ubsan/TestCases/Integer | |
| parent | 98052537f0fd0e627b92704f6a13b4d84d7971e8 (diff) | |
| download | bcm5719-llvm-081a24e3a7cf26c5190699ea8567786c9cb01797.tar.gz bcm5719-llvm-081a24e3a7cf26c5190699ea8567786c9cb01797.zip | |
[UBSan] Implement runtime suppressions (PR25066).
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
llvm-svn: 256018
Diffstat (limited to 'compiler-rt/test/ubsan/TestCases/Integer')
| -rw-r--r-- | compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp b/compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp new file mode 100644 index 00000000000..ce3a5469c12 --- /dev/null +++ b/compiler-rt/test/ubsan/TestCases/Integer/suppressions.cpp @@ -0,0 +1,33 @@ +// RUN: %clangxx -fsanitize=integer -g0 %s -o %t + +// Fails without any suppression. +// RUN: %env_ubsan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s + +// RUN: echo "signed-integer-overflow:%t" > %t.wrong-supp +// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.wrong-supp" not %run %t 2>&1 | FileCheck %s + +// RUN: echo "unsigned-integer-overflow:do_overflow" > %t.func-supp +// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.func-supp" %run %t +// RUN: echo "unsigned-integer-overflow:%t" > %t.module-supp +// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.module-supp" %run %t + +// Note: file-level suppressions should work even without debug info. +// RUN: echo "unsigned-integer-overflow:%s" > %t.file-supp +// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.file-supp" %run %t + +// Suppressions don't work for unrecoverable kinds. +// RUN: %clangxx -fsanitize=integer -fno-sanitize-recover=integer %s -o %t-norecover +// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.module-supp" not %run %t-norecover 2>&1 | FileCheck %s + +#include <stdint.h> + +extern "C" void do_overflow() { + (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull)); + // CHECK: runtime error: unsigned integer overflow +} + +int main() { + do_overflow(); + return 0; +} + |

