JDevlieghere created this revision.
JDevlieghere added reviewers: davide, vsk.
Herald added a subscriber: teemperor.
Herald added a project: LLDB.

For security reasons, `DYLD_INSERT_LIBRARIES` is not propagated to a child 
process. This breaks the `skipIfSanitized` decorator, which checks for the 
environment variable being set. Instead, always set the `ASAN_OPTIONS` and make 
the decorator check for that.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D65594

Files:
  lldb/lit/Suite/lit.cfg
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
  lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py


Index: 
lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
+++ lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
@@ -108,7 +108,7 @@
 
     @add_test_categories(['pyapi'])
     @skipIfiOSSimulator
-    @skipIfSanitized # FIXME: Hangs indefinitely.
+    @skipIfAsan # FIXME: Hangs indefinitely.
     @expectedFailureNetBSD
     def test_with_attach_to_process_with_name_api(self):
         """Create target, spawn a process, and attach to it with process 
name."""
Index: lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
@@ -21,7 +21,7 @@
     @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
     @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], 
bugnumber="rdar://problem/34559552") # this exec test has problems on ios 
systems
     @expectedFailureNetBSD
-    @skipIfSanitized # rdar://problem/43756823
+    @skipIfAsan # rdar://problem/43756823
     @skipIfWindows
     def test_hitting_exec (self):
         self.do_test(False)
@@ -29,7 +29,7 @@
     @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
     @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], 
bugnumber="rdar://problem/34559552") # this exec test has problems on ios 
systems
     @expectedFailureNetBSD
-    @skipIfSanitized # rdar://problem/43756823
+    @skipIfAsan # rdar://problem/43756823
     @skipIfWindows
     def test_skipping_exec (self):
         self.do_test(True)
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -821,11 +821,10 @@
                 return "%s is not supported on this system." % feature
     return skipTestIfFn(is_feature_enabled)
 
-def skipIfSanitized(func):
+def skipIfAsan(func):
     """Skip this test if the environment is set up to run LLDB itself under 
ASAN."""
-    def is_sanitized():
-        if (('DYLD_INSERT_LIBRARIES' in os.environ) and
-                'libclang_rt.asan' in os.environ['DYLD_INSERT_LIBRARIES']):
+    def is_asan():
+        if ('ASAN_OPTIONS' in os.environ):
             return "ASAN unsupported"
         return None
-    return skipTestIfFn(is_sanitized)(func)
+    return skipTestIfFn(is_asan)(func)
Index: lldb/lit/Suite/lit.cfg
===================================================================
--- lldb/lit/Suite/lit.cfg
+++ lldb/lit/Suite/lit.cfg
@@ -20,18 +20,16 @@
                                        'Python', 'lldbsuite', 'test')
 config.test_exec_root = config.test_source_root
 
-# macOS flags needed for LLDB built with address sanitizer.
-if 'Address' in config.llvm_use_sanitizer and \
-   'Darwin' in config.host_os and \
-   'x86' in config.host_triple:
-  import subprocess
-  resource_dir = subprocess.check_output(
-    config.cmake_cxx_compiler +' -print-resource-dir', shell=True).strip()
-  runtime = os.path.join(resource_dir, 'lib', 'darwin',
-                         'libclang_rt.asan_osx_dynamic.dylib')
-  config.environment['ASAN_OPTIONS'] = \
-    'detect_stack_use_after_return=1'
-  config.environment['DYLD_INSERT_LIBRARIES'] = runtime
+if 'Address' in config.llvm_use_sanitizer:
+  config.environment['ASAN_OPTIONS'] = 'detect_stack_use_after_return=1'
+  # macOS flags needed for LLDB built with address sanitizer.
+  if 'Darwin' in config.host_os and 'x86' in config.host_triple:
+    import subprocess
+    resource_dir = subprocess.check_output(
+        [config.cmake_cxx_compiler, '-print-resource-dir']).strip()
+    runtime = os.path.join(resource_dir, 'lib', 'darwin',
+                           'libclang_rt.asan_osx_dynamic.dylib')
+    config.environment['DYLD_INSERT_LIBRARIES'] = runtime
 
 # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 def find_shlibpath_var():


Index: lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
+++ lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
@@ -108,7 +108,7 @@
 
     @add_test_categories(['pyapi'])
     @skipIfiOSSimulator
-    @skipIfSanitized # FIXME: Hangs indefinitely.
+    @skipIfAsan # FIXME: Hangs indefinitely.
     @expectedFailureNetBSD
     def test_with_attach_to_process_with_name_api(self):
         """Create target, spawn a process, and attach to it with process name."""
Index: lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
@@ -21,7 +21,7 @@
     @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
     @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
     @expectedFailureNetBSD
-    @skipIfSanitized # rdar://problem/43756823
+    @skipIfAsan # rdar://problem/43756823
     @skipIfWindows
     def test_hitting_exec (self):
         self.do_test(False)
@@ -29,7 +29,7 @@
     @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
     @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
     @expectedFailureNetBSD
-    @skipIfSanitized # rdar://problem/43756823
+    @skipIfAsan # rdar://problem/43756823
     @skipIfWindows
     def test_skipping_exec (self):
         self.do_test(True)
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -821,11 +821,10 @@
                 return "%s is not supported on this system." % feature
     return skipTestIfFn(is_feature_enabled)
 
-def skipIfSanitized(func):
+def skipIfAsan(func):
     """Skip this test if the environment is set up to run LLDB itself under ASAN."""
-    def is_sanitized():
-        if (('DYLD_INSERT_LIBRARIES' in os.environ) and
-                'libclang_rt.asan' in os.environ['DYLD_INSERT_LIBRARIES']):
+    def is_asan():
+        if ('ASAN_OPTIONS' in os.environ):
             return "ASAN unsupported"
         return None
-    return skipTestIfFn(is_sanitized)(func)
+    return skipTestIfFn(is_asan)(func)
Index: lldb/lit/Suite/lit.cfg
===================================================================
--- lldb/lit/Suite/lit.cfg
+++ lldb/lit/Suite/lit.cfg
@@ -20,18 +20,16 @@
                                        'Python', 'lldbsuite', 'test')
 config.test_exec_root = config.test_source_root
 
-# macOS flags needed for LLDB built with address sanitizer.
-if 'Address' in config.llvm_use_sanitizer and \
-   'Darwin' in config.host_os and \
-   'x86' in config.host_triple:
-  import subprocess
-  resource_dir = subprocess.check_output(
-    config.cmake_cxx_compiler +' -print-resource-dir', shell=True).strip()
-  runtime = os.path.join(resource_dir, 'lib', 'darwin',
-                         'libclang_rt.asan_osx_dynamic.dylib')
-  config.environment['ASAN_OPTIONS'] = \
-    'detect_stack_use_after_return=1'
-  config.environment['DYLD_INSERT_LIBRARIES'] = runtime
+if 'Address' in config.llvm_use_sanitizer:
+  config.environment['ASAN_OPTIONS'] = 'detect_stack_use_after_return=1'
+  # macOS flags needed for LLDB built with address sanitizer.
+  if 'Darwin' in config.host_os and 'x86' in config.host_triple:
+    import subprocess
+    resource_dir = subprocess.check_output(
+        [config.cmake_cxx_compiler, '-print-resource-dir']).strip()
+    runtime = os.path.join(resource_dir, 'lib', 'darwin',
+                           'libclang_rt.asan_osx_dynamic.dylib')
+    config.environment['DYLD_INSERT_LIBRARIES'] = runtime
 
 # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 def find_shlibpath_var():
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to