[Lldb-commits] [lldb] f002fc0 - [lldb] Skip tests that are incompatible with MTE (#186043)

via lldb-commits lldb-commits at lists.llvm.org
Sat Mar 14 11:19:31 PDT 2026


Author: Jonas Devlieghere
Date: 2026-03-14T11:19:26-07:00
New Revision: f002fc0ee87342835f82760b686bbcaa7ac2af04

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

LOG: [lldb] Skip tests that are incompatible with MTE (#186043)

Skip tests that are incompatible with MTE. 

Depends on:
- https://github.com/llvm/llvm-project/pull/185780

Added: 
    

Modified: 
    lldb/cmake/modules/LLDBConfig.cmake
    lldb/packages/Python/lldbsuite/test/configuration.py
    lldb/packages/Python/lldbsuite/test/decorators.py
    lldb/packages/Python/lldbsuite/test/dotest.py
    lldb/packages/Python/lldbsuite/test/dotest_args.py
    lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py
    lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py
    lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
    lldb/test/API/lit.cfg.py
    lldb/test/API/lit.site.cfg.py.in
    lldb/test/API/lua_api/TestLuaAPI.py
    lldb/test/API/macosx/mte/TestDarwinMTE.py
    lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
    lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
    lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
    lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
    lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
    lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py
    lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
    lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
    lldb/test/CMakeLists.txt
    lldb/test/Shell/Heap/heap-cstr.test
    lldb/test/Shell/lit.cfg.py
    lldb/test/Shell/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 01738b29c7d8b..3e20a228bebea 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -182,6 +182,8 @@ if (APPLE)
   if (LLDB_ENABLE_MTE)
     message(STATUS "Running the LLDB test suite with MTE")
   endif()
+else()
+  set(LLDB_ENABLE_MTE OFF)
 endif()
 
 if (LLDB_ENABLE_PYTHON)

diff  --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py
index f96fd31b17a37..002d775594ff5 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -147,6 +147,9 @@
 # A plugin whose tests will be enabled, like intel-pt.
 enabled_plugins = []
 
+# Whether MTE (Memory Tagging Extension) is enabled.
+mte_enabled = False
+
 # the build type of lldb
 # Typical values include Debug, Release, RelWithDebInfo and MinSizeRel
 cmake_build_type = None

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 2c62ba03f39bc..dfb3557ebb6fb 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1145,6 +1145,17 @@ def is_running_under_asan():
     return None
 
 
+def is_running_under_mte():
+    if configuration.mte_enabled:
+        return "MTE unsupported"
+    return None
+
+
+def skipIfMTE(func):
+    """Skip this test when running with MTE (Memory Tagging Extension) enabled."""
+    return skipTestIfFn(is_running_under_mte)(func)
+
+
 def skipUnlessAddressSanitizer(func):
     """Decorate the item to skip test unless Clang -fsanitize=thread is supported."""
 

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 533be0a065e3a..2bfef9c83aed8 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -469,6 +469,9 @@ def parseOptionsAndInitTestdirs():
     if args.enabled_plugins:
         configuration.enabled_plugins = args.enabled_plugins
 
+    if args.enable_mte:
+        configuration.mte_enabled = True
+
     # Gather all the dirs passed on the command line.
     if len(args.args) > 0:
         configuration.testdirs = [

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index fce9e41cb5385..8f4b623c4b1c9 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -279,6 +279,12 @@ def create_parser():
         metavar="A plugin whose tests will be enabled",
         help="A plugin whose tests will be enabled. The only currently supported plugin is intel-pt.",
     )
+    group.add_argument(
+        "--enable-mte",
+        dest="enable_mte",
+        action="store_true",
+        help="Indicate that the test suite is running with MTE (Memory Tagging Extension) enabled.",
+    )
 
     # Configuration options
     group = parser.add_argument_group("Remote platform options")

diff  --git a/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py b/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py
index 95d81bf8a9992..e638718e5e95e 100644
--- a/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py
+++ b/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py
@@ -11,6 +11,7 @@
 
 class TestPtrRefs(TestBase):
     @skipIfAsan  # The output looks 
diff erent under ASAN.
+    @skipIfMTE  # Heap scanning reads tagged memory with untagged pointers.
     @skipUnlessDarwin
     def test_ptr_refs(self):
         """Test format string functionality."""

diff  --git a/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py b/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py
index 358ab5bb7e0ee..b659f4aec2a44 100644
--- a/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py
+++ b/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py
@@ -85,6 +85,7 @@ def do_new_test(self, frame, expr, expected_value_name):
         self.assertTrue(got_type.IsPointerType())
         self.assertEqual(got_type.GetPointeeType().GetName(), "Struct")
 
+    @skipIfMTE  # Expression evaluation of overridden operator new fails under MTE.
     def test_operator_new(self):
         frame = self.prepare_executable_and_get_frame()
 

diff  --git a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
index 9d8b52ae85420..acecf1981dcf4 100644
--- a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
+++ b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
@@ -11,6 +11,7 @@
 
 class TestPtrRefsObjC(TestBase):
     @skipIfAsan  # The output looks 
diff erent under ASAN.
+    @skipIfMTE  # Heap scanning reads tagged memory with untagged pointers.
     def test_ptr_refs(self):
         """Test the ptr_refs tool on Darwin with Objective-C"""
         self.build()

diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f2a14d1475385..a48cb8c5a9b4a 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -300,6 +300,9 @@ def delete_module_cache(path):
     for plugin in config.enabled_plugins:
         dotest_cmd += ["--enable-plugin", plugin]
 
+if getattr(config, "lldb_enable_mte", False):
+    dotest_cmd += ["--enable-mte"]
+
 # `dotest` args come from three 
diff erent sources:
 # 1. Derived by CMake based on its configs (LLDB_TEST_COMMON_ARGS), which end
 # up in `dotest_common_args_str`.

diff  --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 6cc4542bca75e..0f7630c1e6e44 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -43,6 +43,7 @@ config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
 config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
 config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
 config.lldb_launcher = "@LLDB_LAUNCHER@"
+config.lldb_enable_mte = @LLDB_ENABLE_MTE@
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")

diff  --git a/lldb/test/API/lua_api/TestLuaAPI.py b/lldb/test/API/lua_api/TestLuaAPI.py
index e78ed9de72375..1fb64e7fc20d0 100644
--- a/lldb/test/API/lua_api/TestLuaAPI.py
+++ b/lldb/test/API/lua_api/TestLuaAPI.py
@@ -157,6 +157,7 @@ def get_tests(self):
                     tests.append(filename)
         return tests
 
+    @skipIfMTE  # Lua is not MTE-aware.
     def test_lua_api(self):
         if "LUA_EXECUTABLE" not in os.environ or not os.path.exists(
             os.environ["LUA_EXECUTABLE"]

diff  --git a/lldb/test/API/macosx/mte/TestDarwinMTE.py b/lldb/test/API/macosx/mte/TestDarwinMTE.py
index a70b4b4aed26b..59e8cd8d388c1 100644
--- a/lldb/test/API/macosx/mte/TestDarwinMTE.py
+++ b/lldb/test/API/macosx/mte/TestDarwinMTE.py
@@ -5,6 +5,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+from lldbsuite.test import configuration
 import lldbsuite.test.cpu_feature as cpu_feature
 
 exe_name = "uaf"  # Must match Makefile
@@ -18,7 +19,15 @@ def test_process_launch_memory_tagging(self):
         self.build(make_targets=["binary-plain"])
         self.createTestTarget(self.getBuildArtifact(exe_name))
 
-        self.expect("process launch", substrs=["exited with status = 0"])
+        if configuration.mte_enabled:
+            # When running under the MTE launcher, MTE is inherited by child
+            # processes, so even without --memory-tagging the UAF is caught.
+            self.expect(
+                "process launch",
+                substrs=["stopped", "stop reason = EXC_ARM_MTE_TAG_FAULT"],
+            )
+        else:
+            self.expect("process launch", substrs=["exited with status = 0"])
 
         self.expect(
             "process launch --memory-tagging",

diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 865e6fb7d6c01..3dc11a3ff74f2 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -9,6 +9,7 @@
 import re
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
     SHARED_BUILD_TESTCASE = False
 

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
index 5aa790b1c97e5..7059302048396 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
@@ -5,6 +5,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
     def test_attach_with_vAttach(self):
         self.build()

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
index 398264a70a417..c780be62d517c 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
@@ -5,6 +5,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
     def test_qProcessInfo_returns_running_process(self):
         self.build()

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
index 39aa473322a9f..8ffe8a6aba6c8 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
@@ -4,6 +4,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
     """Test QSaveRegisterState/QRestoreRegisterState support."""
 

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
index 17fc8c1a0f08c..fb563faf98efc 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
@@ -7,6 +7,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
     ENABLE_THREADS_IN_STOP_REPLY_ENTRIES = [
         "read packet: $QListThreadsInStopReply#21",

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py b/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py
index 1a5df1a250184..5119ddaf8365f 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py
@@ -4,6 +4,7 @@
 from lldbsuite.test.lldbdwarf import *
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemote_qMemoryRegion(gdbremote_testcase.GdbRemoteTestCaseBase):
     def test_qMemoryRegionInfo_is_supported(self):
         self.build()

diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index f1c0519ae56d8..717c4da171eeb 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -25,6 +25,7 @@
 # On Linux systems with Yama ptrace_scope = 1 there is a race condition when the
 # debugee enables tracing. See https://github.com/llvm/llvm-project/issues/161510.
 @skipIfLinux
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class LldbGdbServerTestCase(
     gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcodeParser
 ):

diff  --git a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
index 84aab9c969aa4..bbbfa733db2da 100644
--- a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
+++ b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
@@ -8,6 +8,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteAttachWait(gdbremote_testcase.GdbRemoteTestCaseBase):
     def _set_up_inferior(self):
         self._exe_to_attach = "%s_%d" % (self.testMethodName, os.getpid())

diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index d7d745a512002..1edfed8c66427 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -255,6 +255,7 @@ set(LLDB_TEST_SHELL_DISABLE_REMOTE OFF CACHE BOOL "Disable remote Shell tests ex
 # These values are not canonicalized within LLVM.
 llvm_canonicalize_cmake_booleans(
   LLDB_BUILD_INTEL_PT
+  LLDB_ENABLE_MTE
   LLDB_ENABLE_PYTHON
   LLDB_ENABLE_LUA
   LLDB_ENABLE_LZMA

diff  --git a/lldb/test/Shell/Heap/heap-cstr.test b/lldb/test/Shell/Heap/heap-cstr.test
index cabf6d6a25aab..a559a978f6b2f 100644
--- a/lldb/test/Shell/Heap/heap-cstr.test
+++ b/lldb/test/Shell/Heap/heap-cstr.test
@@ -1,5 +1,7 @@
 # REQUIRES: system-darwin
 # REQUIRES: python
+# Heap scanning reads tagged memory with untagged pointers.
+# UNSUPPORTED: lldb-mte
 # RUN: %clang_host %p/Inputs/cstr.c -g -o %t
 # RUN: %lldb -b -s %s -f %t | FileCheck %s
 

diff  --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index cdc0cfe51f7c6..8d28f2d5201b3 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -144,6 +144,9 @@ def calculate_arch_features(arch_string):
 if config.lldb_enable_python:
     config.available_features.add("python")
 
+if getattr(config, "lldb_enable_mte", False):
+    config.available_features.add("lldb-mte")
+
 if config.lldb_enable_lua:
     config.available_features.add("lua")
 

diff  --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in
index b260b2fce90b7..546df37775361 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -36,6 +36,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.lldb_has_lldbrpc = @LLDB_BUILD_LLDBRPC@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.lldb_launcher = "@LLDB_LAUNCHER@"
+config.lldb_enable_mte = @LLDB_ENABLE_MTE@
 # The shell tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")


        


More information about the lldb-commits mailing list