sanitizers: suppress false positive leaks in libtbb
authorMichael Wallner <mike@php.net>
Thu, 12 Nov 2020 11:16:27 +0000 (12:16 +0100)
committerMichael Wallner <mike@php.net>
Thu, 12 Nov 2020 11:21:24 +0000 (12:21 +0100)
test/CMakeLists.txt
test/LeakSanitizer.suppressions [new file with mode: 0644]
test/conf.h.in
test/setup.cpp

index 4b10846628d18fd472be572b6a2e29e62c5df4dd..e2ecf0a27a2b1aa283a423a78c4999518db98d8b 100644 (file)
@@ -21,6 +21,7 @@ endif()
 
 file(GLOB_RECURSE TESTING_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
 set(TESTING_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+set(SOURCES_ROOT ${CMAKE_SOURCE_DIR})
 set_source_files_properties(main.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
 configure_file(conf.h.in conf.h @ONLY)
 add_executable(runtests ${TESTING_SRC})
diff --git a/test/LeakSanitizer.suppressions b/test/LeakSanitizer.suppressions
new file mode 100644 (file)
index 0000000..b5a6615
--- /dev/null
@@ -0,0 +1 @@
+leak:libtbb.so
index 2d2d03601616ebea27c10f1cb0e51f06414dc428..bb8fa0c525574639c7d3f0ac355c6e74238d7694 100644 (file)
@@ -23,5 +23,6 @@
 #cmakedefine HAVE_TBB 1
 #cmakedefine HAVE_WAITID_NOWAIT 1
 
+#cmakedefine SOURCES_ROOT "@SOURCES_ROOT@"
 #cmakedefine TESTING_ROOT "@TESTING_ROOT@"
 #cmakedefine MEMCACHED_BINARY getenv_else("MEMCACHED_BINARY", "@MEMCACHED_BINARY@")
index cfa18e080cceb444a4534834e0aedcbb7ba4468f..22c7c2ada9cfc4060aa1c610f0dca73bb3df034d 100644 (file)
@@ -1,4 +1,5 @@
 #include "mem_config.h"
+#include "test/conf.h"
 #include "test/lib/env.hpp"
 #include "test/lib/random.hpp"
 #include <cstdlib>
@@ -55,6 +56,9 @@ static inline void setup_signals() {
     "verify_asan_link_order=1," \
     "abort_on_error=0," \
     ""
+# define LSAN_OPTIONS \
+  "suppressions=" SOURCES_ROOT "/test/LeakSanitizer.suppressions," \
+  ""
 static inline void setup_asan(char **argv) {
   const auto set = getenv("ASAN_OPTIONS");
 
@@ -64,8 +68,18 @@ static inline void setup_asan(char **argv) {
     perror("exec()");
   }
 }
+static inline void setup_lsan(char **argv) {
+  const auto set = getenv("LSAN_OPTIONS");
+
+  if (!set || !*set) {
+    SET_ENV_EX(lsan, "LSAN_OPTIONS", LSAN_OPTIONS, 0);
+    execvp(argv[0], argv);
+    perror("exec()");
+  }
+}
 #else
 # define setup_asan(a) (void) a
+# define setup_lsan(a) (void) a
 #endif
 
 #if LIBMEMCACHED_WITH_SASL_SUPPORT
@@ -85,6 +99,7 @@ int setup(int &, char ***argv) {
   setup_signals();
   setup_random();
   setup_asan(*argv);
+  setup_lsan(*argv);
   setup_sasl();
 
   return 0;