From: Michael Wallner Date: Thu, 12 Nov 2020 11:16:27 +0000 (+0100) Subject: sanitizers: suppress false positive leaks in libtbb X-Git-Tag: 1.1.0-beta1~112 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=9eeee02fddffb336454a6c08c700bfeb2758756e;p=m6w6%2Flibmemcached sanitizers: suppress false positive leaks in libtbb --- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4b108466..e2ecf0a2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 index 00000000..b5a6615b --- /dev/null +++ b/test/LeakSanitizer.suppressions @@ -0,0 +1 @@ +leak:libtbb.so diff --git a/test/conf.h.in b/test/conf.h.in index 2d2d0360..bb8fa0c5 100644 --- a/test/conf.h.in +++ b/test/conf.h.in @@ -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@") diff --git a/test/setup.cpp b/test/setup.cpp index cfa18e08..22c7c2ad 100644 --- a/test/setup.cpp +++ b/test/setup.cpp @@ -1,4 +1,5 @@ #include "mem_config.h" +#include "test/conf.h" #include "test/lib/env.hpp" #include "test/lib/random.hpp" #include @@ -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;