summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/ubsan/TestCases
Commit message (Collapse)AuthorAgeFilesLines
* [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/decrement ↵Roman Lebedev2019-11-273-0/+364
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (PR44054)(take 2) Summary: Implicit Conversion Sanitizer is *almost* feature complete. There aren't *that* much unsanitized things left, two major ones are increment/decrement (this patch) and bit fields. As it was discussed in [[ https://bugs.llvm.org/show_bug.cgi?id=39519 | PR39519 ]], unlike `CompoundAssignOperator` (which is promoted internally), or `BinaryOperator` (for which we always have promotion/demotion in AST) or parts of `UnaryOperator` (we have promotion/demotion but only for certain operations), for inc/dec, clang omits promotion/demotion altogether, under as-if rule. This is technically correct: https://rise4fun.com/Alive/zPgD As it can be seen in `InstCombineCasts.cpp` `canEvaluateTruncated()`, `add`/`sub`/`mul`/`and`/`or`/`xor` operators can all arbitrarily be extended or truncated: https://github.com/llvm/llvm-project/blob/901cd3b3f62d0c700e5d2c3f97eff97d634bec5e/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1320-L1334 But that has serious implications: 1. Since we no longer model implicit casts, do we pessimise their AST representation and everything that uses it? 2. There is no demotion, so lossy demotion sanitizer does not trigger :] Now, i'm not going to argue about the first problem here, but the second one **needs** to be addressed. As it was stated in the report, this is done intentionally, so changing this in all modes would be considered a penalization/regression. Which means, the sanitization-less codegen must not be altered. It was also suggested to not change the sanitized codegen to the one with demotion, but i quite strongly believe that will not be the wise choice here: 1. One will need to re-engineer the check that the inc/dec was lossy in terms of `@llvm.{u,s}{add,sub}.with.overflow` builtins 2. We will still need to compute the result we would lossily demote. (i.e. the result of wide `add`ition/`sub`traction) 3. I suspect it would need to be done right here, in sanitization. Which kinda defeats the point of using `@llvm.{u,s}{add,sub}.with.overflow` builtins: we'd have two `add`s with basically the same arguments, one of which is used for check+error-less codepath and other one for the error reporting. That seems worse than a single wide op+check. 4. OR, we would need to do that in the compiler-rt handler. Which means we'll need a whole new handler. But then what about the `CompoundAssignOperator`, it would also be applicable for it. So this also doesn't really seem like the right path to me. 5. At least X86 (but likely others) pessimizes all sub-`i32` operations (due to partial register stalls), so even if we avoid promotion+demotion, the computations will //likely// be performed in `i32` anyways. So i'm not really seeing much benefit of not doing the straight-forward thing. While looking into this, i have noticed a few more LLVM middle-end missed canonicalizations, and filed [[ https://bugs.llvm.org/show_bug.cgi?id=44100 | PR44100 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=44102 | PR44102 ]]. Those are not specific to inc/dec, we also have them for `CompoundAssignOperator`, and it can happen for normal arithmetics, too. But if we take some other path in the patch, it will not be applicable here, and we will have most likely played ourselves. TLDR: front-end should emit canonical, easy-to-optimize yet un-optimized code. It is middle-end's job to make it optimal. I'm really hoping reviewers agree with my personal assessment of the path this patch should take.. This originally landed in 9872ea4ed1de4c49300430e4f1f4dfc110a79ab9 but got immediately reverted in cbfa237892e55b7129a1178c9b03f26683d643af because the assertion was faulty. That fault ended up being caused by the enum - while there will be promotion, both types are unsigned, with same width. So we still don't need to sanitize non-signed cases. So far. Maybe the assert will tell us this isn't so. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=44054 | PR44054 ]]. Refs. https://github.com/google/sanitizers/issues/940 Reviewers: rjmccall, erichkeane, rsmith, vsk Reviewed By: erichkeane Subscribers: mehdi_amini, dexonsmith, cfe-commits, #sanitizers, llvm-commits, aaron.ballman, t.p.northover, efriedma, regehr Tags: #llvm, #clang, #sanitizers Differential Revision: https://reviews.llvm.org/D70539
* Revert "[clang][CodeGen] Implicit Conversion Sanitizer: handle ↵Roman Lebedev2019-11-273-364/+0
| | | | | | | | | | increment/decrement (PR44054)" The asssertion that was added does not hold, breaks on test-suite/MultiSource/Applications/SPASS/analyze.c Will reduce the testcase and revisit. This reverts commit 9872ea4ed1de4c49300430e4f1f4dfc110a79ab9, 870f3542d3e0d06d208442bdca6482866b59171b.
* [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/decrement ↵Roman Lebedev2019-11-273-0/+364
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (PR44054) Summary: Implicit Conversion Sanitizer is *almost* feature complete. There aren't *that* much unsanitized things left, two major ones are increment/decrement (this patch) and bit fields. As it was discussed in [[ https://bugs.llvm.org/show_bug.cgi?id=39519 | PR39519 ]], unlike `CompoundAssignOperator` (which is promoted internally), or `BinaryOperator` (for which we always have promotion/demotion in AST) or parts of `UnaryOperator` (we have promotion/demotion but only for certain operations), for inc/dec, clang omits promotion/demotion altogether, under as-if rule. This is technically correct: https://rise4fun.com/Alive/zPgD As it can be seen in `InstCombineCasts.cpp` `canEvaluateTruncated()`, `add`/`sub`/`mul`/`and`/`or`/`xor` operators can all arbitrarily be extended or truncated: https://github.com/llvm/llvm-project/blob/901cd3b3f62d0c700e5d2c3f97eff97d634bec5e/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1320-L1334 But that has serious implications: 1. Since we no longer model implicit casts, do we pessimise their AST representation and everything that uses it? 2. There is no demotion, so lossy demotion sanitizer does not trigger :] Now, i'm not going to argue about the first problem here, but the second one **needs** to be addressed. As it was stated in the report, this is done intentionally, so changing this in all modes would be considered a penalization/regression. Which means, the sanitization-less codegen must not be altered. It was also suggested to not change the sanitized codegen to the one with demotion, but i quite strongly believe that will not be the wise choice here: 1. One will need to re-engineer the check that the inc/dec was lossy in terms of `@llvm.{u,s}{add,sub}.with.overflow` builtins 2. We will still need to compute the result we would lossily demote. (i.e. the result of wide `add`ition/`sub`traction) 3. I suspect it would need to be done right here, in sanitization. Which kinda defeats the point of using `@llvm.{u,s}{add,sub}.with.overflow` builtins: we'd have two `add`s with basically the same arguments, one of which is used for check+error-less codepath and other one for the error reporting. That seems worse than a single wide op+check. 4. OR, we would need to do that in the compiler-rt handler. Which means we'll need a whole new handler. But then what about the `CompoundAssignOperator`, it would also be applicable for it. So this also doesn't really seem like the right path to me. 5. At least X86 (but likely others) pessimizes all sub-`i32` operations (due to partial register stalls), so even if we avoid promotion+demotion, the computations will //likely// be performed in `i32` anyways. So i'm not really seeing much benefit of not doing the straight-forward thing. While looking into this, i have noticed a few more LLVM middle-end missed canonicalizations, and filed [[ https://bugs.llvm.org/show_bug.cgi?id=44100 | PR44100 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=44102 | PR44102 ]]. Those are not specific to inc/dec, we also have them for `CompoundAssignOperator`, and it can happen for normal arithmetics, too. But if we take some other path in the patch, it will not be applicable here, and we will have most likely played ourselves. TLDR: front-end should emit canonical, easy-to-optimize yet un-optimized code. It is middle-end's job to make it optimal. I'm really hoping reviewers agree with my personal assessment of the path this patch should take.. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=44054 | PR44054 ]]. Reviewers: rjmccall, erichkeane, rsmith, vsk Reviewed By: erichkeane Subscribers: mehdi_amini, dexonsmith, cfe-commits, #sanitizers, llvm-commits, aaron.ballman, t.p.northover, efriedma, regehr Tags: #llvm, #clang, #sanitizers Differential Revision: https://reviews.llvm.org/D70539
* [UBSan] Split nullptr-and-nonzero-offset-variable.c in another directionRoman Lebedev2019-10-102-51/+12
| | | | llvm-svn: 374309
* [UBSan] Split nullptr-and-nonzero-offset-variable.cpp into C and C++ variantsRoman Lebedev2019-10-102-13/+42
| | | | | | I do not understand the BB failire, it fully passes locally. llvm-svn: 374306
* [UBSan] Revisit nullptr-and-nonzero-offset-variable.cpp test to hopefully ↵Roman Lebedev2019-10-101-7/+7
| | | | | | make it pass on sanitizer-windows BB llvm-svn: 374298
* [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined ↵Roman Lebedev2019-10-105-6/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | behaviour Summary: Quote from http://eel.is/c++draft/expr.add#4: ``` 4 When an expression J that has integral type is added to or subtracted from an expression P of pointer type, the result has the type of P. (4.1) If P evaluates to a null pointer value and J evaluates to 0, the result is a null pointer value. (4.2) Otherwise, if P points to an array element i of an array object x with n elements ([dcl.array]), the expressions P + J and J + P (where J has the value j) point to the (possibly-hypothetical) array element i+j of x if 0≤i+j≤n and the expression P - J points to the (possibly-hypothetical) array element i−j of x if 0≤i−j≤n. (4.3) Otherwise, the behavior is undefined. ``` Therefore, as per the standard, applying non-zero offset to `nullptr` (or making non-`nullptr` a `nullptr`, by subtracting pointer's integral value from the pointer itself) is undefined behavior. (*if* `nullptr` is not defined, i.e. e.g. `-fno-delete-null-pointer-checks` was *not* specified.) To make things more fun, in C (6.5.6p8), applying *any* offset to null pointer is undefined, although Clang front-end pessimizes the code by not lowering that info, so this UB is "harmless". Since rL369789 (D66608 `[InstCombine] icmp eq/ne (gep inbounds P, Idx..), null -> icmp eq/ne P, null`) LLVM middle-end uses those guarantees for transformations. If the source contains such UB's, said code may now be miscompiled. Such miscompilations were already observed: * https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190826/687838.html * https://github.com/google/filament/pull/1566 Surprisingly, UBSan does not catch those issues ... until now. This diff teaches UBSan about these UB's. `getelementpointer inbounds` is a pretty frequent instruction, so this does have a measurable impact on performance; I've addressed most of the obvious missing folds (and thus decreased the performance impact by ~5%), and then re-performed some performance measurements using my [[ https://github.com/darktable-org/rawspeed | RawSpeed ]] benchmark: (all measurements done with LLVM ToT, the sanitizer never fired.) * no sanitization vs. existing check: average `+21.62%` slowdown * existing check vs. check after this patch: average `22.04%` slowdown * no sanitization vs. this patch: average `48.42%` slowdown Reviewers: vsk, filcab, rsmith, aaron.ballman, vitalybuka, rjmccall, #sanitizers Reviewed By: rsmith Subscribers: kristof.beyls, nickdesaulniers, nikic, ychen, dtzWill, xbolva00, dberris, arphaman, rupprecht, reames, regehr, llvm-commits, cfe-commits Tags: #clang, #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D67122 llvm-svn: 374293
* Remove xfail i386 NetBSD mark in vptr-non-unique-typeinfo.cppKamil Rytarowski2019-09-101-1/+0
| | | | | | This test passes now. llvm-svn: 371575
* [UBSan] Do not overwrite the default print_summary sanitizer option.Max Moroz2019-09-091-0/+11
| | | | | | | | | | | | | | | | | | | | | Summary: This option is true by default in sanitizer common. The default false value was added a while ago without any reasoning in https://github.com/llvm-mirror/compiler-rt/commit/524e934112a593ac081bf2b05aa0d60a67987f05 so, presumably it's safe to remove for consistency. Reviewers: hctim, samsonov, morehouse, kcc, vitalybuka Reviewed By: hctim, samsonov, vitalybuka Subscribers: delcypher, #sanitizers, llvm-commits, kcc Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D67193 llvm-svn: 371442
* compiler-rt: Rename last few cc files below test/ubsan to cppNico Weber2019-08-054-3/+3
| | | | | | See r367803 and similar other changes. llvm-svn: 367855
* compiler-rt: Rename .cc files in lib/ubsan to .cpp.Nico Weber2019-07-311-1/+1
| | | | | | | | | | | See https://reviews.llvm.org/D58620 for discussion, and for the commands I ran. In addition I also ran for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done and manually updated references to renamed files found by that. llvm-svn: 367452
* Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"Stephan Bergmann2019-07-161-3/+64
| | | | | | | | | | | | | | | | | | | | | i.e., recent 5745eccef54ddd3caca278d1d292a88b2281528b: * Bump the function_type_mismatch handler version, as its signature has changed. * The function_type_mismatch handler can return successfully now, so SanitizerKind::Function must be AlwaysRecoverable (like for SanitizerKind::Vptr). * But the minimal runtime would still unconditionally treat a call to the function_type_mismatch handler as failure, so disallow -fsanitize=function in combination with -fsanitize-minimal-runtime (like it was already done for -fsanitize=vptr). * Add tests. Differential Revision: https://reviews.llvm.org/D61479 llvm-svn: 366186
* [ubsan][test] Restore float-divide-by-zero testFangrui Song2019-07-101-0/+1
| | | | | | Removed by rCTE365307 to fix buildbots. It can be restored now because D64317/rC365587 brought back -fsanitize=float-divide-by-zero llvm-svn: 365591
* [ubsan][test] Fix cast-overflow.cpp and delete float-divide-by-zero test ↵Fangrui Song2019-07-082-2/+1
| | | | | | after D63793/rC365272 llvm-svn: 365307
* [ubsan][test] Fix several UBSan-* :: TestCases/ImplicitConversion tests on ↵Rainer Orth2019-07-086-120/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Solaris A couple of UBSan-* :: TestCases/ImplicitConversion testcases FAIL on Solaris/x86 (and Solaris/SPARC with https://reviews.llvm.org/D40900): FAIL: UBSan-AddressSanitizer-i386 :: TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c (49187 of 49849) ******************** TEST 'UBSan-AddressSanitizer-i386 :: TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c' FAILED ******************** [...] Command Output (stderr): -- /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:53:11: error: CHECK: expected string not found in input // CHECK: {{.*}}signed-integer-truncation-or-sign-change-blacklist.c:[[@LINE-1]]:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka 'signed char') changed the value to -1 (8-bit, signed) ^ <stdin>:1:1: note: scanning from here /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:52:10: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type 'int8_t' (aka 'char') changed the value to -1 (8-bit, signed) ^ <stdin>:1:1: note: with "@LINE-1" equal to "52" /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:52:10: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type 'int8_t' (aka 'char') changed the value to -1 (8-bit, signed) ^ <stdin>:1:69: note: possible intended match here /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:52:10: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type 'int8_t' (aka 'char') changed the value to -1 (8-bit, signed) ^ This is always a difference for int8_t where signed char is expected, but only char seen. I could trace this to <sys/int_types.h> which has /* * Basic / Extended integer types * * The following defines the basic fixed-size integer types. * * Implementations are free to typedef them to Standard C integer types or * extensions that they support. If an implementation does not support one * of the particular integer data types below, then it should not define the * typedefs and macros corresponding to that data type. Note that int8_t * is not defined in -Xs mode on ISAs for which the ABI specifies "char" * as an unsigned entity because there is no way to define an eight bit * signed integral. */ #if defined(_CHAR_IS_SIGNED) typedef char int8_t; #else #if defined(__STDC__) typedef signed char int8_t; #endif #endif _CHAR_IS_SIGNED is always defined on both sparc and x86. Since it seems ok to have either form, I've changed the affected tests to use '{{(signed )?}}char' instead of 'signed char'. Tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. Differential Revision: https://reviews.llvm.org/D63984 llvm-svn: 365303
* [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.*Reid Kleckner2019-06-273-0/+0
| | | | | | | | | | | | | These lit configuration files are really Python source code. Using the .py file extension helps editors and tools use the correct language mode. LLVM and Clang already use this convention for lit configuration, this change simply applies it to all of compiler-rt. Reviewers: vitalybuka, dberris Differential Revision: https://reviews.llvm.org/D63658 llvm-svn: 364591
* [ubsan] Make suppressions.cpp test pass for me on WindowsReid Kleckner2019-02-011-1/+4
| | | | | | | | | | | The test seems to be failing because the module suppression file contains a colon. I found that it was sufficient to just use the basename of the suppression file. While I was here, I noticed that we don't implement IsAbsolutePath for Windows, so I added it. llvm-svn: 352921
* Revert "[Sanitizers] UBSan unreachable incompatible with ASan in the ↵Julian Lettner2019-01-241-16/+0
| | | | | | | | presence of `noreturn` calls" This reverts commit cea84ab93aeb079a358ab1c8aeba6d9140ef8b47. llvm-svn: 352069
* Temporarily deactivate tests; it fails on certain botsJulian Lettner2019-01-241-1/+1
| | | | llvm-svn: 352020
* [ubsan] Fix test when isPICDefault() returns false after rCTE352003Fangrui Song2019-01-241-1/+1
| | | | llvm-svn: 352013
* [Sanitizers] UBSan unreachable incompatible with ASan in the presence of ↵Julian Lettner2019-01-241-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `noreturn` calls Summary: UBSan wants to detect when unreachable code is actually reached, so it adds instrumentation before every `unreachable` instruction. However, the optimizer will remove code after calls to functions marked with `noreturn`. To avoid this UBSan removes `noreturn` from both the call instruction as well as from the function itself. Unfortunately, ASan relies on this annotation to unpoison the stack by inserting calls to `_asan_handle_no_return` before `noreturn` functions. This is important for functions that do not return but access the the stack memory, e.g., unwinder functions *like* `longjmp` (`longjmp` itself is actually "double-proofed" via its interceptor). The result is that when ASan and UBSan are combined, the `noreturn` attributes are missing and ASan cannot unpoison the stack, so it has false positives when stack unwinding is used. Changes: # UBSan now adds the `expect_noreturn` attribute whenever it removes the `noreturn` attribute from a function # ASan additionally checks for the presence of this attribute Generated code: ``` call void @__asan_handle_no_return // Additionally inserted to avoid false positives call void @longjmp call void @__asan_handle_no_return call void @__ubsan_handle_builtin_unreachable unreachable ``` The second call to `__asan_handle_no_return` is redundant. This will be cleaned up in a follow-up patch. rdar://problem/40723397 Reviewers: delcypher, eugenis Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D56624 llvm-svn: 352003
* [compiler-rt] alignment-assumption-blacklist.cpp test apparently passes on ↵Roman Lebedev2019-01-151-5/+0
| | | | | | android, un-XFAIL it. llvm-svn: 351184
* [compiler-rt][UBSan] Sanitization for alignment assumptions.Roman Lebedev2019-01-1512-0/+327
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the compiler-rt part. The clang part is D54589. This is a second commit, the original one was r351106, which was mass-reverted in r351159 because 2 compiler-rt tests were failing. Now, i have fundamentally changed the testing approach: i malloc a few bytes, intentionally mis-align the pointer (increment it by one), and check that. Also, i have decreased the expected alignment. This hopefully should be enough to pacify all the bots. If not, i guess i might just drop the two 'bad' tests. Reviewers: filcab, vsk, #sanitizers, vitalybuka, rsmith, morehouse Reviewed By: morehouse Subscribers: rjmccall, krytarowski, rsmith, kcc, srhines, kubamracek, dberris, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54590 llvm-svn: 351178
* Revert alignment assumptions changesVlad Tsyrklevich2019-01-1512-253/+0
| | | | | | | Revert r351104-6, r351109, r351110, r351119, r351134, and r351153. These changes fail on the sanitizer bots. llvm-svn: 351159
* Silence failing testsVlad Tsyrklevich2019-01-152-2/+2
| | | | | | | | | r351134 tried to disable these tests by using 'UNSUPPORTED: *' but '*' is not supported for UNSUPPORTED like it is for XFAIL. Update these tests to use XFAIL for now in order to silence x86_64-linux and x86_64-linux-android. llvm-svn: 351153
* [compiler-rt] UBSan: just completely disable two alignment-assumption tests ↵Roman Lebedev2019-01-142-8/+4
| | | | | | | | | | | | | for now. And they are faling on clang-cmake-armv7-full too. *ONLY* these two. I'm not sure what to make of it. Perhaps doing a malloc and checking that pointer will make them fail as expected? llvm-svn: 351134
* [compiler-rt] UBSan: Disable 3 of the new alignment assumption tests on android.Roman Lebedev2019-01-143-5/+10
| | | | | | | | | | | Once again, just like with r338296, these tests seem to only have failed sanitizer-x86_64-linux-android, so let's just disable them, since that seems like the pre-established practice here.. To be noted, they failed on some configs there, but not all, so it is not XFAIL. llvm-svn: 351119
* [compiler-rt][UBSan] Sanitization for alignment assumptions.Roman Lebedev2019-01-1412-0/+252
| | | | | | | | | | | | | | | | | | Summary: This is the compiler-rt part. The clang part is D54589. Reviewers: filcab, vsk, #sanitizers, vitalybuka, rsmith, morehouse Reviewed By: morehouse Subscribers: rjmccall, krytarowski, rsmith, kcc, srhines, kubamracek, dberris, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54590 llvm-svn: 351106
* [compiler-rt][UBSan] silence_unsigned_overflow: do *NOT* ignore *fatal* ↵Roman Lebedev2018-11-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unsigned overflows Summary: D48660 / rL335762 added a `silence_unsigned_overflow` env flag for [[ https://github.com/google/oss-fuzz/pull/1717 | oss-fuzz needs ]], that allows to silence the reports from unsigned overflows. It makes sense, it is there because `-fsanitize=integer` sanitizer is not enabled on oss-fuzz, so this allows to still use it as an interestingness signal, without getting the actual reports. However there is a slight problem here. All types of unsigned overflows are ignored. Even if `-fno-sanitize-recover=unsigned` was used (which means the program will die after the report) there will still be no report, the program will just silently die. At the moment there are just two projects on oss-fuzz that care: * [[ https://github.com/google/oss-fuzz/blob/8eeffa627f937040aaf8ba1b7d93f43f77d74fb9/projects/llvm_libcxx/build.sh#L18-L20 | libc++ ]] * [[ https://github.com/google/oss-fuzz/blob/8eeffa627f937040aaf8ba1b7d93f43f77d74fb9/projects/librawspeed/build.sh | RawSpeed ]] (me) I suppose this could be overridden there ^, but i really don't think this is intended behavior in any case.. Reviewers: kcc, Dor1s, #sanitizers, filcab, vsk, kubamracek Reviewed By: Dor1s Subscribers: dberris, mclow.lists, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54771 llvm-svn: 347415
* Adapt UBSan integer truncation tests to NetBSDKamil Rytarowski2018-11-0610-198/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The NetBSD headers use internal indirect type for standard *int*_t definitions. The internal type is unrolled inside the sanitizer into e.g. __int32_t from int32_t. This symbol mangling causes pattern mismatch in the interger truncation tests as they expect exact types such as 'int32_t'. Change the pattern rules so every acceptable internal form of *int*_t will be accepted flawlessly. Reviewers: lebedev.ri, vitalybuka, joerg Reviewed By: lebedev.ri Subscribers: kubamracek, dmgreen, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54150 llvm-svn: 346228
* [UBsan] disable few tests for FreeBSDDavid Carlier2018-11-052-0/+4
| | | | | | | | | | Reviewers: krytarowsky, vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D54103 llvm-svn: 346145
* [NFC][compiler-rt] Cleanup Implicit Conversion Sanitizer tests to use sized ↵Roman Lebedev2018-10-309-240/+248
| | | | | | | | | | | | | | | | | | types Summary: As requested by @filcab in https://reviews.llvm.org/D50251#1280267 Reviewers: filcab, vsk, #sanitizers, vitalybuka Reviewed By: filcab, #sanitizers, vitalybuka Subscribers: vitalybuka, kubamracek, dberris, llvm-commits, filcab Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D53869 llvm-svn: 345661
* [compiler-rt][ubsan] Implicit Conversion Sanitizer - integer sign change - ↵Roman Lebedev2018-10-307-3/+780
| | | | | | | | | | | | | | | | | | | | | | compiler-rt part Summary: This is a compiler-rt part. The clang part is D50250. See [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], https://github.com/google/sanitizers/issues/940. Reviewers: vsk, filcab, #sanitizers Reviewed By: filcab, #sanitizers Subscribers: mclow.lists, srhines, kubamracek, dberris, rjmccall, rsmith, llvm-commits, regehr Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D50251 llvm-svn: 345659
* Mark vptr-non-unique-typeinfo as a broken test for NetBSD/i386Kamil Rytarowski2018-10-301-0/+1
| | | | llvm-svn: 345654
* [compiler-rt][ubsan] Split Implicit Integer Truncation Sanitizer into ↵Roman Lebedev2018-10-117-28/+753
| | | | | | | | | | | | | | | | unsigned and signed checks Summary: This is compiler-rt part. clang part is D50901. Reviewers: rsmith, vsk, filcab, Sanitizers Reviewed by: filcab Differential Revision: https://reviews.llvm.org/D50902 llvm-svn: 344231
* [compiler-rt][ubsan][NFC] Slight test cleanup in preparation for D50902.Roman Lebedev2018-09-272-90/+605
| | | | | | | | | | | | Reviewers: vsk, vitalybuka, filcab Reviewed By: vitalybuka Subscribers: kubamracek, dberris, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D52590 llvm-svn: 343250
* [UBSan] Partially fix `test/ubsan/TestCases/Misc/log-path_test.cc` so that ↵Dan Liew2018-09-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it can run on devices. Summary: In order for this test to work the log file needs to be removed from both from the host and device. To fix this the `rm` `RUN` lines have been replaced with `RUN: rm` followed by `RUN: %device_rm`. Initially I tried having it so that `RUN: %run rm` implicitly runs `rm` on the host as well so that only one `RUN` line is needed. This simplified writing the test however that had two large drawbacks. * It's potentially very confusing (e.g. for use of the device scripts outside of the lit tests) if asking for `rm` to run on device also causes files on the host to be deleted. * This doesn't work well with the glob patterns used in the test. The host shell expands the `%t.log.*` glob pattern and not on the device so we could easily miss deleting old log files from previous test runs if the corresponding file doesn't exist on the host. So instead deletion of files on the device and host are explicitly separate commands. The command to delete files from a device is provided by a new substitution `%device_rm` as suggested by Filipe Cabecinhas. The semantics of `%device_rm` are that: * It provides a way remove files from a target device when the host is not the same as the target. In the case that the host and target are the same it is a no-op. * It interprets shell glob patterns in the context of the device file system instead of the host file system. This solves the globbing problem provided the argument is quoted so that lit's underlying shell doesn't try to expand the glob pattern. * It supports the `-r` and `-f` flags of the `rm` command, with the same semantics. Right now an implementation of `%device_rm` is provided only for ios devices. For all other devices a lit warning is emitted and the `%device_rm` is treated as a no-op. This done to avoid changing the behaviour for other device types but leaves room for others to implement `%device_rm`. The ios device implementation uses the `%run` wrapper to do the work of removing files on a device. The `iossim_run.py` script has been fixed so that it just runs `rm` on the host operating system because the device and host file system are the same. rdar://problem/41126835 Reviewers: vsk, kubamracek, george.karpenkov, eugenis Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D51648 llvm-svn: 342391
* [UBSan] Add missing `%run` prefixes to Pointer tests.Dan Liew2018-09-032-4/+4
| | | | | | | | | | | | Summary: rdar://problem/41126835 Reviewers: vsk, kubamracek Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D51271 llvm-svn: 341298
* [NFC] Some small test updates for Implicit Conversion sanitizer.Roman Lebedev2018-08-172-5/+81
| | | | | | Split off from D50251. llvm-svn: 339996
* [CMake] Use normalized Windows target triplesPetr Hosek2018-08-0910-10/+10
| | | | | | | | | | | Changes the default Windows target triple returned by GetHostTriple.cmake from the old environment names (which we wanted to move away from) to newer, normalized ones. This also requires updating all tests to use the new systems names in constraints. Differential Revision: https://reviews.llvm.org/D47381 llvm-svn: 339307
* [NFC] Rename test/ubsan/TestCases/{ImplicitCast => ImplicitConversion}Roman Lebedev2018-07-303-0/+0
| | | | | | | | Just to be consistent with the rest. I should have done that in the commit itself, but the filepaths is one thing i forgot to verify :S llvm-svn: 338307
* [compiler-rt] integer-truncation-blacklist.c: XFAIL on android/iosRoman Lebedev2018-07-301-0/+5
| | | | | | | | | | | | | | | The Builder sanitizer-x86_64-linux-android is failing starting with rL338287 / D48959. It runs the tests via android_compile.py, so i'm not sure this is actually *this* issue: https://code.google.com/p/address-sanitizer/issues/detail?id=316 but this seems oddly similar to the other XFAIL'ed cases... Right now that seems to be the only failing builder, so i *think* it makes sense to try to just blacklist it for now. llvm-svn: 338296
* [compiler-rt][ubsan] Implicit Conversion Sanitizer - integer truncation - ↵Roman Lebedev2018-07-303-0/+91
| | | | | | | | | | | | | | | | | | | | | | compiler-rt part Summary: This is a compiler-rt part. The clang part is D48958. See [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], https://github.com/google/sanitizers/issues/940. Reviewers: #sanitizers, samsonov, vsk, rsmith, pcc, eugenis, kcc, filcab Reviewed By: #sanitizers, vsk, filcab Subscribers: llvm-commits, eugenis, filcab, kubamracek, dberris, #sanitizers, regehr Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D48959 llvm-svn: 338287
* [test] Use printf instead of C++ iostream, NFC.Jonas Hahnfeld2018-07-261-4/+4
| | | | | | | | | | | This test fails with libc++ when built with MemorySanitizer. This is because we link to an uninstrumented version of the library so msan detects a nested error when calling std::cout << "...". This can be easily avoided by using good old printf. Differential Revision: https://reviews.llvm.org/D49867 llvm-svn: 338053
* [UBSan] Followup for silence_unsigned_overflow flag to handle negate overflows.Max Moroz2018-07-131-1/+3
| | | | | | | | | | | | | | | | | | | | Summary: That flag has been introduced in https://reviews.llvm.org/D48660 for suppressing UIO error messages in an efficient way. The main motivation is to be able to use UIO checks in builds used for fuzzing as it might provide an interesting signal to a fuzzing engine such as libFuzzer. See https://github.com/google/oss-fuzz/issues/910 for more information. Reviewers: morehouse, kcc Reviewed By: morehouse Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D49324 llvm-svn: 337068
* [compiler-rt] Get rid of "%T" expansionsFilipe Cabecinhas2018-07-101-7/+7
| | | | | | | | | | | | | | | | | | | Summary: Original patch by Kuba Mracek The %T lit expansion expands to a common directory shared between all the tests in the same directory, which is unexpected and unintuitive, and more importantly, it's been a source of subtle race conditions and flaky tests. In https://reviews.llvm.org/D35396, it was agreed that it would be best to simply ban %T and only keep %t, which is unique to each test. When a test needs a temporary directory, it can just create one using mkdir %t. This patch removes %T in compiler-rt. Differential Revision: https://reviews.llvm.org/D48618 llvm-svn: 336661
* [UBsan] Enable subset of unit tests for OpenBSDDavid Carlier2018-06-307-0/+14
| | | | | | | | | | Reviewers: kubamracek, krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D48805 llvm-svn: 336053
* [UBSan] Add silence_unsigned_overflow flag.Matt Morehouse2018-06-271-0/+2
| | | | | | | | | | | | | | | | | | | | Summary: Setting UBSAN_OPTIONS=silence_unsigned_overflow=1 will silence all UIO reports. This feature, combined with -fsanitize-recover=unsigned-integer-overflow, is useful for providing fuzzing signal without the excessive log output. Helps with https://github.com/google/oss-fuzz/issues/910. Reviewers: kcc, vsk Reviewed By: vsk Subscribers: vsk, kubamracek, Dor1s, llvm-commits Differential Revision: https://reviews.llvm.org/D48660 llvm-svn: 335762
* [ubsan] Mark a test case as unsupported on WindowsVedant Kumar2018-06-251-2/+7
| | | | | | | | | __ubsan_on_report isn't defined as weak, and redefining it in a test is not supported on Windows. See the error message here: https://reviews.llvm.org/D48446 llvm-svn: 335523
* [ubsan] Add support for reporting diagnostics to a monitor processVedant Kumar2018-06-221-0/+37
| | | | | | | | | | | | | | | | | | Add support to the ubsan runtime for reporting diagnostics to a monitor process (e.g a debugger). The Xcode IDE uses this by setting a breakpoint on __ubsan_on_report and collecting diagnostic information via __ubsan_get_current_report_data, which it then surfaces to users in the editor UI. Testing for this functionality already exists in upstream lldb, here: lldb/packages/Python/lldbsuite/test/functionalities/ubsan Apart from that, this is `ninja check-{a,ub}san` clean. Differential Revision: https://reviews.llvm.org/D48446 llvm-svn: 335371
OpenPOWER on IntegriCloud