From ebfeeec4c4bcc4373e5d5dfaff7ee75959a7c931 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Mon, 22 Nov 2021 14:51:09 -0500 Subject: [PATCH] [libunwind] Fix testing with sanitizers enabled When testing with sanitizers enabled, we need to link against a plethora of system libraries. Using `-nodefaultlibs` like we used to breaks this, and we would have to add all these system libraries manually, which is not portable and error prone. Instead, stop using `-nodefaultlibs` so that we get the libraries added by default by the compiler. The only caveat with this approach is that we are now relying on the fact that `-L ` will cause the just built libunwind to be selected before the system implementation (either of libunwind or libgcc_s.so), which is somewhat fragile. This patch also turns the 32 bit multilib build into a soft failure since we are in the process of removing it anyway, see D114473 for details. This patch is incompatible with the 32 bit multilib build because Ubuntu does not provide a proper libstdc++ for 32 bits, and that is required when running with sanitizers enabled. Differential Revision: https://reviews.llvm.org/D114385 --- libcxx/utils/ci/buildkite-pipeline.yml | 2 ++ libunwind/test/configs/llvm-libunwind-shared.cfg.in | 2 +- libunwind/test/configs/llvm-libunwind-static.cfg.in | 2 +- libunwind/test/forceunwind.pass.cpp | 3 --- libunwind/test/frameheadercache_test.pass.cpp | 3 --- libunwind/test/libunwind_01.pass.cpp | 3 --- libunwind/test/libunwind_02.pass.cpp | 3 --- libunwind/test/remember_state_leak.pass.sh.s | 3 --- libunwind/test/signal_frame.pass.cpp | 3 --- libunwind/test/signal_unwind.pass.cpp | 3 --- libunwind/test/unw_getcontext.pass.cpp | 3 --- libunwind/test/unwind_leaffunction.pass.cpp | 9 ++------- 12 files changed, 6 insertions(+), 33 deletions(-) diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml index 96e2cb3..08e0bce 100644 --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -385,6 +385,8 @@ steps: automatic: - exit_status: -1 # Agent was lost limit: 2 + soft_fail: + - exit_status: 1 timeout_in_minutes: 120 - label: "Single-threaded" diff --git a/libunwind/test/configs/llvm-libunwind-shared.cfg.in b/libunwind/test/configs/llvm-libunwind-shared.cfg.in index 206c2b9..9de82e9 100644 --- a/libunwind/test/configs/llvm-libunwind-shared.cfg.in +++ b/libunwind/test/configs/llvm-libunwind-shared.cfg.in @@ -47,7 +47,7 @@ config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I {}/include {}'.format('@LIBUNWIND_SOURCE_DIR@', ' '.join(compile_flags)) )) config.substitutions.append(('%{link_flags}', - '-nodefaultlibs -L {0} -Wl,-rpath,{0} -lunwind -ldl -lc {1}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags)) + '-L {0} -Wl,-rpath,{0} -lunwind -ldl {1}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags)) )) config.substitutions.append(('%{exec}', '')) diff --git a/libunwind/test/configs/llvm-libunwind-static.cfg.in b/libunwind/test/configs/llvm-libunwind-static.cfg.in index dd292e7..9382ad3 100644 --- a/libunwind/test/configs/llvm-libunwind-static.cfg.in +++ b/libunwind/test/configs/llvm-libunwind-static.cfg.in @@ -49,7 +49,7 @@ config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I {}/include {}'.format('@LIBUNWIND_SOURCE_DIR@', ' '.join(compile_flags)) )) config.substitutions.append(('%{link_flags}', - '-nodefaultlibs {}/libunwind.a -ldl -lc {}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags)) + '{}/libunwind.a -ldl {}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags)) )) config.substitutions.append(('%{exec}', '')) diff --git a/libunwind/test/forceunwind.pass.cpp b/libunwind/test/forceunwind.pass.cpp index 1206632..4666972 100644 --- a/libunwind/test/forceunwind.pass.cpp +++ b/libunwind/test/forceunwind.pass.cpp @@ -9,9 +9,6 @@ // REQUIRES: linux -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - // Basic test for _Unwind_ForcedUnwind. // See libcxxabi/test/forced_unwind* tests too. diff --git a/libunwind/test/frameheadercache_test.pass.cpp b/libunwind/test/frameheadercache_test.pass.cpp index a50b2b6..9abff5e 100644 --- a/libunwind/test/frameheadercache_test.pass.cpp +++ b/libunwind/test/frameheadercache_test.pass.cpp @@ -1,6 +1,3 @@ -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - // The other libunwind tests don't test internal interfaces, so the include path // is a little wonky. #include "../src/config.h" diff --git a/libunwind/test/libunwind_01.pass.cpp b/libunwind/test/libunwind_01.pass.cpp index 6c1e1bb..e573745 100644 --- a/libunwind/test/libunwind_01.pass.cpp +++ b/libunwind/test/libunwind_01.pass.cpp @@ -1,6 +1,3 @@ -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - // TODO: Investigate these failures on x86_64 macOS back deployment // UNSUPPORTED: target=x86_64-apple-darwin{{.+}} diff --git a/libunwind/test/libunwind_02.pass.cpp b/libunwind/test/libunwind_02.pass.cpp index 6eea7a3..b188fad 100644 --- a/libunwind/test/libunwind_02.pass.cpp +++ b/libunwind/test/libunwind_02.pass.cpp @@ -1,6 +1,3 @@ -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - #include #include #include diff --git a/libunwind/test/remember_state_leak.pass.sh.s b/libunwind/test/remember_state_leak.pass.sh.s index b98a91d0..df1512d 100644 --- a/libunwind/test/remember_state_leak.pass.sh.s +++ b/libunwind/test/remember_state_leak.pass.sh.s @@ -2,9 +2,6 @@ # RUN: %{build} # RUN: %{run} -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - // TODO: Investigate this failure // XFAIL: 32bits-on-64bits diff --git a/libunwind/test/signal_frame.pass.cpp b/libunwind/test/signal_frame.pass.cpp index 513eef5..85a883b 100644 --- a/libunwind/test/signal_frame.pass.cpp +++ b/libunwind/test/signal_frame.pass.cpp @@ -9,9 +9,6 @@ // Ensure that functions marked as signal frames are reported as such. -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - // TODO: Investigate this failure on macOS // XFAIL: target={{.+}}-apple-darwin{{.+}} diff --git a/libunwind/test/signal_unwind.pass.cpp b/libunwind/test/signal_unwind.pass.cpp index 12d9589..c16adeb 100644 --- a/libunwind/test/signal_unwind.pass.cpp +++ b/libunwind/test/signal_unwind.pass.cpp @@ -10,9 +10,6 @@ // Ensure that the unwinder can cope with the signal handler. // REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}}) -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - #include #include #include diff --git a/libunwind/test/unw_getcontext.pass.cpp b/libunwind/test/unw_getcontext.pass.cpp index a02c8e5..a1f2bae 100644 --- a/libunwind/test/unw_getcontext.pass.cpp +++ b/libunwind/test/unw_getcontext.pass.cpp @@ -1,6 +1,3 @@ -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - #include #include diff --git a/libunwind/test/unwind_leaffunction.pass.cpp b/libunwind/test/unwind_leaffunction.pass.cpp index 4037455..2a6d831 100644 --- a/libunwind/test/unwind_leaffunction.pass.cpp +++ b/libunwind/test/unwind_leaffunction.pass.cpp @@ -10,9 +10,6 @@ // Ensure that leaf function can be unwund. // REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}}) -// TODO: Investigate these failures -// XFAIL: asan, tsan, ubsan - #include #include #include @@ -41,14 +38,12 @@ void signal_handler(int signum) { _Exit(-1); } -int* faultyPointer = NULL; - __attribute__((noinline)) void crashing_leaf_func(void) { - *faultyPointer = 0; + raise(SIGSEGV); } int main(int, char**) { signal(SIGSEGV, signal_handler); crashing_leaf_func(); return -2; -} \ No newline at end of file +} -- 2.7.4