[Lldb-commits] [lldb] 4d4024e - [lldb] Set MallocNanoZone for all sanitizers when running tests

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 6 09:59:42 PST 2024


Author: Jonas Devlieghere
Date: 2024-11-06T09:59:35-08:00
New Revision: 4d4024e1edf354113e8d0d11661d466ae5b0bee7

URL: https://github.com/llvm/llvm-project/commit/4d4024e1edf354113e8d0d11661d466ae5b0bee7
DIFF: https://github.com/llvm/llvm-project/commit/4d4024e1edf354113e8d0d11661d466ae5b0bee7.diff

LOG: [lldb] Set MallocNanoZone for all sanitizers when running tests

Disabling MallocNanoZone is necessary for both ASan and TSan.

Added: 
    

Modified: 
    lldb/test/API/lit.cfg.py
    lldb/test/Shell/lit.cfg.py
    lldb/test/Unit/lit.cfg.py
    lldb/test/Unit/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index c8e4a4c461f123..6ef09f36a1907e 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -127,13 +127,13 @@ def delete_module_cache(path):
 
 
 if is_configured("llvm_use_sanitizer"):
+    config.environment["MallocNanoZone"] = "0"
     if "Address" in config.llvm_use_sanitizer:
         config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
         if "Darwin" in config.host_os:
             config.environment["DYLD_INSERT_LIBRARIES"] = find_sanitizer_runtime(
                 "libclang_rt.asan_osx_dynamic.dylib"
             )
-            config.environment["MallocNanoZone"] = "0"
 
     if "Thread" in config.llvm_use_sanitizer:
         config.environment["TSAN_OPTIONS"] = "halt_on_error=1"

diff  --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 24c910d2fc561a..6ca180b6f5c95a 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -50,14 +50,10 @@
 )
 
 # Enable sanitizer runtime flags.
-if "Address" in config.llvm_use_sanitizer:
+if config.llvm_use_sanitizer:
     config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
-    if platform.system() == "Darwin":
-        config.environment["MallocNanoZone"] = "0"
-
-if "Thread" in config.llvm_use_sanitizer:
     config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
-
+    config.environment["MallocNanoZone"] = "0"
 
 if config.lldb_platform_url and config.cmake_sysroot and config.enable_remote:
     if re.match(r".*-linux.*", config.target_triple):

diff  --git a/lldb/test/Unit/lit.cfg.py b/lldb/test/Unit/lit.cfg.py
index 1dda6569a7b3cc..8d711f17d858e6 100644
--- a/lldb/test/Unit/lit.cfg.py
+++ b/lldb/test/Unit/lit.cfg.py
@@ -35,8 +35,10 @@
 llvm_config.with_environment("PATH", os.path.dirname(sys.executable), append_path=True)
 
 # Enable sanitizer runtime flags.
-config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
-config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if config.llvm_use_sanitizer:
+    config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
+    config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+    config.environment["MallocNanoZone"] = "0"
 
 # testFormat: The test format to use to interpret tests.
 config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests")

diff  --git a/lldb/test/Unit/lit.site.cfg.py.in b/lldb/test/Unit/lit.site.cfg.py.in
index b22af0f381439f..2748be229cf1ce 100644
--- a/lldb/test/Unit/lit.site.cfg.py.in
+++ b/lldb/test/Unit/lit.site.cfg.py.in
@@ -9,6 +9,7 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.python_executable = "@Python3_EXECUTABLE@"
 
 import lit.llvm


        


More information about the lldb-commits mailing list