JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, mgorny.
Herald added a subscriber: abidh.
Herald added a project: LLDB.

Setting `DYLD_INSERT_LIBRARIES` to the Asan runtime and `DYLD_LIBRARY_PATH ` to 
the LLVM shared library dir causes the test suite to crash with a segfault. We 
see this on the LLDB sanitized bot [1] on GreenDragon. I've spent some time 
investigating, but I'm not sure what's going on (yet).

Originally I thought this was because we were building compiler-rt and were 
loading an incompatible, just-built Asan library. However, the issue persists 
even without compiler-rt. It doesn't look like the Asan runtime is opening any 
other libraries that might be found in LLVM's shared library dir and talking to 
the team confirms that. Another possible explanation is that we're loading lldb 
form a place we don't expect, but that doesn't make sense either, because 
`DYLD_LIBRARY_PATH` is always set without the crash. I tried different Python 
versions and interpreters but the issue persist.

As a (temporary?) workaround I propose not setting `DYLD_LIBRARY_PATH` when 
`DYLD_INSERT_LIBRARIES` is set so we can turn the Asan bot on again and get 
useful results.

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D66845

Files:
  lldb/lit/Suite/lit.cfg


Index: lldb/lit/Suite/lit.cfg
===================================================================
--- lldb/lit/Suite/lit.cfg
+++ lldb/lit/Suite/lit.cfg
@@ -31,7 +31,6 @@
                            '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():
   if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
     yield 'LD_LIBRARY_PATH'
@@ -40,18 +39,21 @@
   elif platform.system() == 'Windows':
     yield 'PATH'
 
-for shlibpath_var in find_shlibpath_var():
-  # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory
-  # while llvm_libs_dir specifies LLVM's lib directory.
-  shlibpath = os.path.pathsep.join(
-    (config.llvm_shlib_dir,
-     config.llvm_libs_dir,
-     config.environment.get(shlibpath_var, '')))
-  config.environment[shlibpath_var] = shlibpath
-  break
-else:
-  lit_config.warning("unable to inject shared library path on '{}'"
-                     .format(platform.system()))
+if not config.environment['DYLD_INSERT_LIBRARIES']:
+  # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
+  # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
+  for shlibpath_var in find_shlibpath_var():
+    # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
+    # llvm_libs_dir specifies LLVM's lib directory.
+    shlibpath = os.path.pathsep.join(
+      (config.llvm_shlib_dir,
+      config.llvm_libs_dir,
+      config.environment.get(shlibpath_var, '')))
+    config.environment[shlibpath_var] = shlibpath
+    break
+  else:
+    lit_config.warning("unable to inject shared library path on '{}'"
+                      .format(platform.system()))
 
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']


Index: lldb/lit/Suite/lit.cfg
===================================================================
--- lldb/lit/Suite/lit.cfg
+++ lldb/lit/Suite/lit.cfg
@@ -31,7 +31,6 @@
                            '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():
   if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
     yield 'LD_LIBRARY_PATH'
@@ -40,18 +39,21 @@
   elif platform.system() == 'Windows':
     yield 'PATH'
 
-for shlibpath_var in find_shlibpath_var():
-  # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory
-  # while llvm_libs_dir specifies LLVM's lib directory.
-  shlibpath = os.path.pathsep.join(
-    (config.llvm_shlib_dir,
-     config.llvm_libs_dir,
-     config.environment.get(shlibpath_var, '')))
-  config.environment[shlibpath_var] = shlibpath
-  break
-else:
-  lit_config.warning("unable to inject shared library path on '{}'"
-                     .format(platform.system()))
+if not config.environment['DYLD_INSERT_LIBRARIES']:
+  # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
+  # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
+  for shlibpath_var in find_shlibpath_var():
+    # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
+    # llvm_libs_dir specifies LLVM's lib directory.
+    shlibpath = os.path.pathsep.join(
+      (config.llvm_shlib_dir,
+      config.llvm_libs_dir,
+      config.environment.get(shlibpath_var, '')))
+    config.environment[shlibpath_var] = shlibpath
+    break
+  else:
+    lit_config.warning("unable to inject shared library path on '{}'"
+                      .format(platform.system()))
 
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] ... Jonas Devlieghere via Phabricator via lldb-commits

Reply via email to