[compiler-rt] r351398 - Fix sanitizer tool list used to generate sanitizer_common tests to be up-to-date.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 16 15:37:32 PST 2019


Author: delcypher
Date: Wed Jan 16 15:37:31 2019
New Revision: 351398

URL: http://llvm.org/viewvc/llvm-project?rev=351398&view=rev
Log:
Fix sanitizer tool list used to generate sanitizer_common tests to be up-to-date.

Summary:
This replaces the sanitizer tool list (used for generating
sanitizer_common configurations) with a tool list derived from
existing build system information.

Previously sanitizer_common had its own list of supported sanitizer
tools. This was bad because it was out of sync with the rest of the
build system. Notably it meant that the sanitizer_common runtime was
only being tested on Darwin the ASan dylib and not the other sanitizer
dylibs that are built for Darwin (LSan, TSan, and UBSan).

Unfortunately enabling the tests against other sanitizer dylibs has lead
to some test failures on Darwin. For now they've been marked as
XFAIL until the failures can investigated properly.

For Windows and Android we use the old sanitizer tool list to try avoid
bot breakages.

rdar://problem/47143078

Reviewers: kubamracek, george.karpenkov, yln, samsonov, vitalybuka, krytarowski

Subscribers: srhines, mgorny, fedor.sergeev, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D55740

Modified:
    compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt
    compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/print-stack-trace.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/symbolize_stack.cc

Modified: compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt?rev=351398&r1=351397&r2=351398&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt Wed Jan 16 15:37:31 2019
@@ -3,17 +3,41 @@ set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CM
 set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
 set(SANITIZER_COMMON_TESTSUITES)
 
+# FIXME(dliew): We should switch to COMPILER_RT_SANITIZERS_TO_BUILD instead of
+# the hard coded `SUPPORTED_TOOLS_INIT` list once we know that the other
+# sanitizers work.
+set(SUPPORTED_TOOLS_INIT asan lsan msan tsan ubsan)
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|SunOS")
-  list(APPEND SUPPORTED_TOOLS asan)
-endif()
-if(CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID))
-  list(APPEND SUPPORTED_TOOLS tsan)
-  list(APPEND SUPPORTED_TOOLS msan)
-  list(APPEND SUPPORTED_TOOLS ubsan)
-endif()
-if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
-  list(APPEND SUPPORTED_TOOLS lsan)
+  foreach(SANITIZER_TOOL ${SUPPORTED_TOOLS_INIT})
+    string(TOUPPER ${SANITIZER_TOOL} SANITIZER_TOOL_UPPER)
+    if (COMPILER_RT_HAS_${SANITIZER_TOOL_UPPER})
+      list(APPEND SUPPORTED_TOOLS ${SANITIZER_TOOL})
+    endif()
+  endforeach()
+
+# FIXME(dliew): Remove this.
+# Temporary helper for https://reviews.llvm.org/D55740
+message(
+  STATUS
+  "Generated Sanitizer SUPPORTED_TOOLS list on \"${CMAKE_SYSTEM_NAME}\" is"
+  " \"${SUPPORTED_TOOLS}\"")
+
+# FIXME(dliew): These tests should be made to work on all platforms.
+# Use the legacy list for now.
+if (ANDROID OR WINDOWS)
+  set(OLD_SUPPORTED_TOOLS ${SUPPORTED_TOOLS})
+  if (ANDROID)
+    set(SUPPORTED_TOOLS asan)
+  elseif (WINDOWS)
+    set(SUPPORTED_TOOLS "")
+  else()
+    message(FATAL_ERROR "Unhandled platform")
+  endif()
+	message(
+		AUTHOR_WARNING
+    "Replacing Sanitizer SUPPORTED_TOOLS list (${OLD_SUPPORTED_TOOLS}) with "
+    "\"${SUPPORTED_TOOLS}\"")
+  unset(OLD_SUPPORTED_TOOLS)
 endif()
 
 # FIXME(dliew): Remove this.
@@ -34,6 +58,8 @@ foreach(tool ${SUPPORTED_TOOLS})
     darwin_filter_host_archs(${tool_toupper}_SUPPORTED_ARCH TEST_ARCH)
   endif()
 
+  # TODO(dliew): We should iterate over the different
+  # Apple platforms, not just macOS.
   foreach(arch ${TEST_ARCH})
     set(SANITIZER_COMMON_LIT_TEST_MODE ${tool})
     set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch})
@@ -42,8 +68,14 @@ foreach(tool ${SUPPORTED_TOOLS})
     configure_lit_site_cfg(
       ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
       ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
-    list(APPEND SANITIZER_COMMON_TESTSUITES
-         ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
+    # FIXME(dliew): LSan i386 on Darwin is completly broken right now.
+    # so don't run the tests by default.
+    if (NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin" AND
+             ${tool} STREQUAL "lsan" AND
+             ${arch} STREQUAL "i386"))
+      list(APPEND SANITIZER_COMMON_TESTSUITES
+           ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
+    endif()
   endforeach()
 endforeach()
 

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc?rev=351398&r1=351397&r2=351398&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc Wed Jan 16 15:37:31 2019
@@ -1,7 +1,7 @@
 // Check that sanitizers on OS X crash the process by default (i.e.
 // abort_on_error=1). See also Linux/abort_on_error.cc.
 
-// RUN: %clangxx %s -o %t
+// RUN: %clangxx -DUSING_%tool_name %s -o %t
 
 // Intentionally don't inherit the default options.
 // RUN: env %tool_options='' not --crash %run %t 2>&1
@@ -9,11 +9,19 @@
 // When we use lit's default options, we shouldn't crash.
 // RUN: not %run %t 2>&1
 
+// Leak detection isn't treated as an error so `abort_on_error=1` doesn't work.
+// UNSUPPORTED: lsan
+
 int global;
 
 int main() {
+#if defined(USING_ubsan)
+  int value = 5;
+  int computation = value / 0; // Division by zero.
+#else
   volatile int *a = new int[100];
   delete[] a;
-  global = a[0];  // use-after-free: triggers ASan report.
+  global = a[0]; // use-after-free: triggers ASan/TSan report.
+#endif
   return 0;
 }

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/print-stack-trace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/print-stack-trace.cc?rev=351398&r1=351397&r2=351398&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/print-stack-trace.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/print-stack-trace.cc Wed Jan 16 15:37:31 2019
@@ -1,6 +1,9 @@
 // RUN: %clangxx -O0 %s -o %t && %env_tool_opts=stack_trace_format=DEFAULT %run %t 2>&1 | FileCheck %s
 // RUN: %env_tool_opts=stack_trace_format='"frame:%n lineno:%l"' %run %t 2>&1 | FileCheck %s --check-prefix=CUSTOM
 
+// FIXME(dliew): Make this test work with other sanitizers
+// XFAIL: darwin && (lsan || tsan || ubsan)
+
 #include <sanitizer/common_interface_defs.h>
 
 static inline void FooBarBaz() {

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc?rev=351398&r1=351397&r2=351398&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc Wed Jan 16 15:37:31 2019
@@ -10,6 +10,9 @@
 
 // XFAIL: netbsd && !asan
 
+// FIXME(dliew): Make this test work with other sanitizers
+// XFAIL: darwin && (lsan || tsan || ubsan)
+
 volatile int *null = 0;
 
 namespace Xyz {

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc?rev=351398&r1=351397&r2=351398&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc Wed Jan 16 15:37:31 2019
@@ -3,6 +3,8 @@
 // REQUIRES: stable-runtime
 
 // XFAIL: ubsan
+// FIXME(dliew): Make this test work on Darwin with LSan
+// XFAIL: darwin && lsan
 
 #include <sanitizer/common_interface_defs.h>
 #include <stdio.h>

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/symbolize_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/symbolize_stack.cc?rev=351398&r1=351397&r2=351398&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/symbolize_stack.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/symbolize_stack.cc Wed Jan 16 15:37:31 2019
@@ -2,6 +2,9 @@
 
 // Test that symbolizer does not crash on frame with large function name.
 
+// FIXME(dliew): Make this test work with the other sanitizers.
+// XFAIL: darwin && (lsan || tsan || ubsan)
+
 #include <sanitizer/common_interface_defs.h>
 #include <vector>
 




More information about the llvm-commits mailing list