diff options
| author | Evgenii Stepanov <eugenis@google.com> | 2019-10-29 15:04:43 -0700 |
|---|---|---|
| committer | Evgenii Stepanov <eugenis@google.com> | 2019-10-31 10:22:52 -0700 |
| commit | 2f856a36e0b270b184051d10a18d4b4238b4c033 (patch) | |
| tree | f820b97783621599cb23bb56d2bcb286c00f27f8 /compiler-rt/lib/msan/tests | |
| parent | cb19ea45a71b74c72ad5e8ceaa42a0b6c8168576 (diff) | |
| download | bcm5719-llvm-2f856a36e0b270b184051d10a18d4b4238b4c033.tar.gz bcm5719-llvm-2f856a36e0b270b184051d10a18d4b4238b4c033.zip | |
[msan] Blacklist __gxx_personality_v0.
Summary:
Fixes https://bugs.llvm.org/show_bug.cgi?id=31877.
Fixes https://github.com/google/sanitizers/issues/1155.
Enables exceptions in msan/tsan buid of libcxx, and in msan tests.
-fdepfile-entry stuff is a workaround for
https://reviews.llvm.org/D69290 (default blacklist missing from -MMD
output).
Reviewers: pcc, dvyukov
Subscribers: mgorny, christof, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D69587
Diffstat (limited to 'compiler-rt/lib/msan/tests')
| -rw-r--r-- | compiler-rt/lib/msan/tests/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/tests/msan_test.cpp | 29 |
2 files changed, 35 insertions, 4 deletions
diff --git a/compiler-rt/lib/msan/tests/CMakeLists.txt b/compiler-rt/lib/msan/tests/CMakeLists.txt index 9949e81a2c1..541356fc68d 100644 --- a/compiler-rt/lib/msan/tests/CMakeLists.txt +++ b/compiler-rt/lib/msan/tests/CMakeLists.txt @@ -8,7 +8,9 @@ include_directories(../..) set(MSAN_LIBCXX_CFLAGS -fsanitize=memory -fsanitize-memory-track-origins - -Wno-pedantic) + -Wno-pedantic + -Xclang -fdepfile-entry=${COMPILER_RT_OUTPUT_DIR}/share/msan_blacklist.txt + ) # Unittest sources and build flags. set(MSAN_UNITTEST_SOURCES @@ -32,7 +34,6 @@ set(MSAN_UNITTEST_COMMON_CFLAGS -I${COMPILER_RT_SOURCE_DIR}/lib/msan -g -O2 - -fno-exceptions -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wno-deprecated-declarations @@ -114,13 +115,14 @@ macro(add_msan_tests_for_arch arch kind cflags) set(MSAN_TEST_OBJECTS ${MSAN_INST_TEST_OBJECTS} ${MSAN_INST_GTEST}) set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-build - ${MSAN_LOADABLE_SO}) + ${MSAN_LOADABLE_SO} + "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a") if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND MSAN_TEST_DEPS msan) endif() get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS) add_compiler_rt_test(MsanUnitTests "Msan-${arch}${kind}-Test" ${arch} - OBJECTS ${MSAN_TEST_OBJECTS} "${MSAN_LIBCXX_DIR}/libc++.a" + OBJECTS ${MSAN_TEST_OBJECTS} "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a" DEPS ${MSAN_TEST_DEPS} LINK_FLAGS ${MSAN_UNITTEST_LINK_FLAGS} ${TARGET_LINK_FLAGS}) diff --git a/compiler-rt/lib/msan/tests/msan_test.cpp b/compiler-rt/lib/msan/tests/msan_test.cpp index c1cae3dad1f..2d67b6ff645 100644 --- a/compiler-rt/lib/msan/tests/msan_test.cpp +++ b/compiler-rt/lib/msan/tests/msan_test.cpp @@ -4798,3 +4798,32 @@ TEST(MemorySanitizer, Bmi) { } } #endif // defined(__x86_64__) + +namespace { +volatile long z; + +__attribute__((noinline,optnone)) void f(long a, long b, long c, long d, long e, long f) { + z = a + b + c + d + e + f; +} + +__attribute__((noinline,optnone)) void throw_stuff() { + throw 5; +} + +TEST(MemorySanitizer, throw_catch) { + long x; + // Poison __msan_param_tls. + __msan_poison(&x, sizeof(x)); + f(x, x, x, x, x, x); + try { + // This calls __gxx_personality_v0 through some libgcc_s function. + // __gxx_personality_v0 is instrumented, libgcc_s is not; as a result, + // __msan_param_tls is not updated and __gxx_personality_v0 can find + // leftover poison from the previous call. + // A suppression in msan_blacklist.txt makes it work. + throw_stuff(); + } catch (const int &e) { + // pass + } +} +} // namespace |

