[libunwind] Fix testing with sanitizers enabled
authorLouis Dionne <ldionne.2@gmail.com>
Mon, 22 Nov 2021 19:51:09 +0000 (14:51 -0500)
committerLouis Dionne <ldionne.2@gmail.com>
Thu, 25 Nov 2021 20:28:17 +0000 (15:28 -0500)
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 <path-to-local-libunwind>` 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

12 files changed:
libcxx/utils/ci/buildkite-pipeline.yml
libunwind/test/configs/llvm-libunwind-shared.cfg.in
libunwind/test/configs/llvm-libunwind-static.cfg.in
libunwind/test/forceunwind.pass.cpp
libunwind/test/frameheadercache_test.pass.cpp
libunwind/test/libunwind_01.pass.cpp
libunwind/test/libunwind_02.pass.cpp
libunwind/test/remember_state_leak.pass.sh.s
libunwind/test/signal_frame.pass.cpp
libunwind/test/signal_unwind.pass.cpp
libunwind/test/unw_getcontext.pass.cpp
libunwind/test/unwind_leaffunction.pass.cpp

index 96e2cb3..08e0bce 100644 (file)
@@ -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"
index 206c2b9..9de82e9 100644 (file)
@@ -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}', ''))
 
index dd292e7..9382ad3 100644 (file)
@@ -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}', ''))
 
index 1206632..4666972 100644 (file)
@@ -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.
 
index a50b2b6..9abff5e 100644 (file)
@@ -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"
index 6c1e1bb..e573745 100644 (file)
@@ -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{{.+}}
 
index 6eea7a3..b188fad 100644 (file)
@@ -1,6 +1,3 @@
-// TODO: Investigate these failures
-// XFAIL: asan, tsan, ubsan
-
 #include <assert.h>
 #include <stdlib.h>
 #include <unwind.h>
index b98a91d..df1512d 100644 (file)
@@ -2,9 +2,6 @@
 # RUN: %{build}
 # RUN: %{run}
 
-// TODO: Investigate these failures
-// XFAIL: asan, tsan, ubsan
-
 // TODO: Investigate this failure
 // XFAIL: 32bits-on-64bits
 
index 513eef5..85a883b 100644 (file)
@@ -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{{.+}}
 
index 12d9589..c16adeb 100644 (file)
@@ -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 <assert.h>
 #include <dlfcn.h>
 #include <signal.h>
index a02c8e5..a1f2bae 100644 (file)
@@ -1,6 +1,3 @@
-// TODO: Investigate these failures
-// XFAIL: asan, tsan, ubsan
-
 #include <assert.h>
 #include <libunwind.h>
 
index 4037455..2a6d831 100644 (file)
@@ -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 <assert.h>
 #include <dlfcn.h>
 #include <signal.h>
@@ -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
+}