From 4e2035d7b4730d535ebd7619c4e85878f71f8cb2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 12 Mar 2018 02:46:26 +0100 Subject: [PATCH] disable dlopen when under sanitizers --- CMakeLists.txt | 4 ++++ src/smpi/internals/smpi_global.cpp | 7 +++++++ tools/cmake/src/internal_config.h.in | 2 ++ tools/tesh/tesh.py | 1 + 4 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51590bce4d..b16aeab13a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -618,6 +618,10 @@ endif() file(REMOVE test_stackgrowth) #-------------------------------------------------------------------------------------------------- +if(enable_address_sanitizer OR enable_thread_sanitizer OR enable_undefined_sanitizer) + set(HAVE_SANITIZER 1) +endif() + ### check for addr2line find_path(ADDR2LINE NAMES addr2line PATHS NO_DEFAULT_PATHS) if(ADDR2LINE) diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 769c00900d..0c1a3b7f89 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -388,6 +388,13 @@ static void smpi_init_options(){ } #endif +#if defined(HAVE_SANITIZER) + if (smpi_privatize_global_variables == SMPI_PRIVATIZE_DLOPEN) { + XBT_INFO("Sanitizers don't like dlopen, switching to mmap privatization instead."); + smpi_privatize_global_variables = SMPI_PRIVATIZE_MMAP; + } +#endif + if (smpi_cpu_threshold < 0) smpi_cpu_threshold = DBL_MAX; diff --git a/tools/cmake/src/internal_config.h.in b/tools/cmake/src/internal_config.h.in index aac7ce0a3e..90d8c70ba7 100644 --- a/tools/cmake/src/internal_config.h.in +++ b/tools/cmake/src/internal_config.h.in @@ -109,3 +109,5 @@ #cmakedefine01 HAVE_GRAPHVIZ /* The lib unwind library (for MC and backtrace display) */ #cmakedefine01 HAVE_LIBUNWIND +/* Whether we are built under a sanitizer (to disable dlopen privatization) */ +#cmakedefine01 HAVE_SANITIZER diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index a37449ee68..2cd1dce335 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -467,6 +467,7 @@ if __name__ == '__main__': re.compile(r"cmake: /usr/local/lib/libcurl\.so\.4: no version information available \(required by cmake\)"), # Seen on CircleCI re.compile(r".*mmap broken on FreeBSD, but dlopen\+thread broken too. Switching to dlopen\+raw contexts\."), re.compile(r".*dlopen\+thread broken on Apple and BSD\. Switching to raw contexts\."), + re.compile(r"Sanitizers don.t like dlopen, switching to mmap privatization instead\."), ] TeshState().jenkins = True # This is a Jenkins build -- 2.20.1