summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgenii Stepanov <eugenis@google.com>2019-10-29 15:04:43 -0700
committerEvgenii Stepanov <eugenis@google.com>2019-10-31 10:22:52 -0700
commit2f856a36e0b270b184051d10a18d4b4238b4c033 (patch)
treef820b97783621599cb23bb56d2bcb286c00f27f8
parentcb19ea45a71b74c72ad5e8ceaa42a0b6c8168576 (diff)
downloadbcm5719-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
-rw-r--r--compiler-rt/cmake/Modules/AddCompilerRT.cmake1
-rw-r--r--compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt2
-rw-r--r--compiler-rt/lib/msan/CMakeLists.txt1
-rw-r--r--compiler-rt/lib/msan/msan_blacklist.txt3
-rw-r--r--compiler-rt/lib/msan/tests/CMakeLists.txt10
-rw-r--r--compiler-rt/lib/msan/tests/msan_test.cpp29
6 files changed, 41 insertions, 5 deletions
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 7c9505e66ce..b87ab6a91d4 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -623,6 +623,7 @@ macro(add_custom_libcxx name prefix)
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
EXCLUDE_FROM_ALL TRUE
+ BUILD_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
)
if (CMAKE_GENERATOR MATCHES "Make")
diff --git a/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt b/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
index 3b1eb910ec8..e61c222587e 100644
--- a/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
+++ b/compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
@@ -4,7 +4,7 @@ project(custom-libcxx C CXX)
# Build static libcxxabi.
set(LIBCXXABI_STANDALONE_BUILD 1)
set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_EXCEPTIONS ON CACHE BOOL "")
set(LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE STRING "")
set(LIBCXXABI_LIBCXX_PATH ${COMPILER_RT_LIBCXX_PATH} CACHE PATH "")
set(LIBCXXABI_INCLUDE_TESTS OFF CACHE BOOL "")
diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt
index 9e9bf654393..86e96a01a11 100644
--- a/compiler-rt/lib/msan/CMakeLists.txt
+++ b/compiler-rt/lib/msan/CMakeLists.txt
@@ -81,6 +81,7 @@ foreach(arch ${MSAN_SUPPORTED_ARCH})
endforeach()
add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt msan)
+list(APPEND MSAN_RUNTIME_LIBRARIES msan_blacklist)
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(tests)
diff --git a/compiler-rt/lib/msan/msan_blacklist.txt b/compiler-rt/lib/msan/msan_blacklist.txt
index 44a5680d4d0..3efef571218 100644
--- a/compiler-rt/lib/msan/msan_blacklist.txt
+++ b/compiler-rt/lib/msan/msan_blacklist.txt
@@ -5,3 +5,6 @@
# Example usage:
# fun:*bad_function_name*
# src:file_with_tricky_code.cc
+
+# https://bugs.llvm.org/show_bug.cgi?id=31877
+fun:__gxx_personality_*
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
OpenPOWER on IntegriCloud