diff options
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 |

