[libunwind] [libunwind][test] Avoid calling back into libunwind on sanitizer errors (PR #67861)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 29 15:14:20 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libunwind
<details>
<summary>Changes</summary>
The libunwind tests currently trigger MSan diagnostics, but while printing those diagnostics MSan calls back into libunwind to print a stack trace. And then this stack trace triggers another nested MSan fault which ends up recursing infinitely and overflowing the stack.
This change works around this by setting the fast_unwind_on_fatal=1 config option in the evironment for MSan and ASan.
---
Full diff: https://github.com/llvm/llvm-project/pull/67861.diff
7 Files Affected:
- (modified) libunwind/test/configs/apple-libunwind-backdeployment.cfg.in (+1-1)
- (modified) libunwind/test/configs/cmake-bridge.cfg.in (+8)
- (modified) libunwind/test/configs/ibm-libunwind-shared.cfg.in (+1-1)
- (modified) libunwind/test/configs/llvm-libunwind-merged.cfg.in (+1-1)
- (modified) libunwind/test/configs/llvm-libunwind-mingw.cfg.in (+1-1)
- (modified) libunwind/test/configs/llvm-libunwind-shared.cfg.in (+1-1)
- (modified) libunwind/test/configs/llvm-libunwind-static.cfg.in (+1-1)
``````````diff
diff --git a/libunwind/test/configs/apple-libunwind-backdeployment.cfg.in b/libunwind/test/configs/apple-libunwind-backdeployment.cfg.in
index 4484573801bd2ba..c26008df2a07348 100644
--- a/libunwind/test/configs/apple-libunwind-backdeployment.cfg.in
+++ b/libunwind/test/configs/apple-libunwind-backdeployment.cfg.in
@@ -51,7 +51,7 @@ config.substitutions.append(('%{link_flags}',
'-nostdlib++ -L %{lib} -lc++ -lc++abi -lunwind'
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T --env DYLD_LIBRARY_PATH="%{cxx-runtime-root}:%{abi-runtime-root}:%{unwind-runtime-root}" -- '
+ f'%{{executor}} --execdir %T --env DYLD_LIBRARY_PATH="%{{cxx-runtime-root}}:%{{abi-runtime-root}}:%{{unwind-runtime-root}}"{config.extra_executor_env} -- '
))
config.stdlib = 'apple-libc++'
diff --git a/libunwind/test/configs/cmake-bridge.cfg.in b/libunwind/test/configs/cmake-bridge.cfg.in
index c5f34c87abb92a1..5393020961b8925 100644
--- a/libunwind/test/configs/cmake-bridge.cfg.in
+++ b/libunwind/test/configs/cmake-bridge.cfg.in
@@ -28,6 +28,14 @@ if @LIBUNWIND_USES_ARM_EHABI@:
if not @LIBUNWIND_ENABLE_THREADS@:
config.available_features.add('libunwind-no-threads')
+config.extra_executor_env = ""
+if "Memory" in config.use_sanitizer:
+ # Avoid calling back into libunwind if we detect a MSan error
+ config.extra_executor_env += " --env MSAN_OPTIONS=fast_unwind_on_fatal=1"
+if "Address" in config.use_sanitizer:
+ # Avoid calling back into libunwind if we detect an ASan error
+ config.extra_executor_env += " --env ASAN_OPTIONS=fast_unwind_on_fatal=1"
+
# Add substitutions for bootstrapping the test suite configuration
import shlex
config.substitutions.append(('%{cxx}', shlex.quote('@CMAKE_CXX_COMPILER@')))
diff --git a/libunwind/test/configs/ibm-libunwind-shared.cfg.in b/libunwind/test/configs/ibm-libunwind-shared.cfg.in
index c38d278ad2c9cd4..d70534a9e3dd38b 100644
--- a/libunwind/test/configs/ibm-libunwind-shared.cfg.in
+++ b/libunwind/test/configs/ibm-libunwind-shared.cfg.in
@@ -11,7 +11,7 @@ config.substitutions.append(('%{link_flags}',
'-nostdlib++ -L %{lib} -lunwind -ldl -Wl,-bbigtoc'
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T --env LIBPATH=%{lib} -- '
+ f'%{{executor}} --execdir %T --env LIBPATH=%{{lib}}{config.extra_executor_env} -- '
))
import os, site
diff --git a/libunwind/test/configs/llvm-libunwind-merged.cfg.in b/libunwind/test/configs/llvm-libunwind-merged.cfg.in
index 38b79840c9fe282..e15336ceb1eee94 100644
--- a/libunwind/test/configs/llvm-libunwind-merged.cfg.in
+++ b/libunwind/test/configs/llvm-libunwind-merged.cfg.in
@@ -32,7 +32,7 @@ config.substitutions.append(('%{link_flags}',
'-L %{{lib}} -Wl,-rpath,%{{lib}} -lc++ {}'.format(' '.join(link_flags))
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T -- '
+ f'%{{executor}} --execdir %T{config.extra_executor_env}-- '
))
import os, site
diff --git a/libunwind/test/configs/llvm-libunwind-mingw.cfg.in b/libunwind/test/configs/llvm-libunwind-mingw.cfg.in
index 33d061a3efc6fc5..900c2279d72b525 100644
--- a/libunwind/test/configs/llvm-libunwind-mingw.cfg.in
+++ b/libunwind/test/configs/llvm-libunwind-mingw.cfg.in
@@ -11,7 +11,7 @@ config.substitutions.append(('%{link_flags}',
'-L %{lib} -lunwind'
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T --prepend_env PATH=%{lib} -- '
+ f'%{{executor}} --execdir %T --prepend_env PATH=%{{lib}}{config.extra_executor_env} -- '
))
import os, site
diff --git a/libunwind/test/configs/llvm-libunwind-shared.cfg.in b/libunwind/test/configs/llvm-libunwind-shared.cfg.in
index 13896aeb13bc4a9..8c3891986ab7f3d 100644
--- a/libunwind/test/configs/llvm-libunwind-shared.cfg.in
+++ b/libunwind/test/configs/llvm-libunwind-shared.cfg.in
@@ -31,7 +31,7 @@ config.substitutions.append(('%{link_flags}',
'-L %{{lib}} -Wl,-rpath,%{{lib}} -lunwind {}'.format(' '.join(link_flags))
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T -- '
+ f'%{{executor}} --execdir %T{config.extra_executor_env} -- '
))
import os, site
diff --git a/libunwind/test/configs/llvm-libunwind-static.cfg.in b/libunwind/test/configs/llvm-libunwind-static.cfg.in
index 50b64dc665a5af5..a39eb34215157fe 100644
--- a/libunwind/test/configs/llvm-libunwind-static.cfg.in
+++ b/libunwind/test/configs/llvm-libunwind-static.cfg.in
@@ -34,7 +34,7 @@ config.substitutions.append(('%{link_flags}',
'%{{lib}}/libunwind.a {}'.format(' '.join(link_flags))
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T -- '
+ f'%{{executor}} --execdir %T{config.extra_executor_env} -- '
))
import os, site
``````````
</details>
https://github.com/llvm/llvm-project/pull/67861
More information about the cfe-commits
mailing list