From ac191bcc99e2fc4ab7993138f5e82a0b75b7e9db Mon Sep 17 00:00:00 2001 From: Leonard Chan Date: Wed, 22 Sep 2021 15:25:05 -0700 Subject: [PATCH] [compiler-rt][test] Add REQUIRES for checking static libc++abi intercept-rethrow-exception.cc fails when running runtimes tests if linking in a hermetic libc++abi. This is because if libc++abi is used, then asan expects to intercept __cxa_rethrow_primary_exception on linux, which should unpoison the stack. If we statically link in libc++abi though, it will contain a strong definition for __cxa_rethrow_primary_exception which wins over the weakly defined interceptor provided by asan, causing the test to fail by not unpoisoning the stack on the exception being thrown. It's likely no one has encountered this before and possible that upstream tests opt for dynamically linking where the interceptor can work properly. An ideal long term solution would be to update the interceptor and libc++[abi] APIs to work for this case, but that will likely take a long time to work out. In the meantime, since the test isn't necessarily broken, we can just add another REQUIRES check to make sure that it's only run if we aren't statically linking in libc++abi. Differential Revision: https://reviews.llvm.org/D109938 --- compiler-rt/CMakeLists.txt | 1 + compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp | 2 ++ compiler-rt/test/lit.common.cfg.py | 3 +++ compiler-rt/test/lit.common.configured.in | 1 + 4 files changed, 7 insertions(+) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index fc8a0cf..4bbcf9a 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -241,6 +241,7 @@ endif() option(SANITIZER_USE_STATIC_CXX_ABI "Use static libc++abi." ${DEFAULT_SANITIZER_USE_STATIC_CXX_ABI}) +pythonize_bool(SANITIZER_USE_STATIC_CXX_ABI) set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY OFF) if (FUCHSIA) diff --git a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp index c3944d6..4c549b6 100644 --- a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp +++ b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp @@ -1,6 +1,8 @@ // Regression test for // https://bugs.llvm.org/show_bug.cgi?id=32434 +// REQUIRES: shared_cxxabi + // RUN: %clangxx_asan -fexceptions -O0 %s -o %t // RUN: %run %t diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index 0515475..ca9047b 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -363,6 +363,9 @@ sanitizer_can_use_cxxabi = getattr(config, 'sanitizer_can_use_cxxabi', True) if sanitizer_can_use_cxxabi: config.available_features.add('cxxabi') +if not getattr(config, 'sanitizer_uses_static_cxxabi', False): + config.available_features.add('shared_cxxabi') + if config.has_lld: config.available_features.add('lld-available') diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in index 71c2c72..be4501b 100644 --- a/compiler-rt/test/lit.common.configured.in +++ b/compiler-rt/test/lit.common.configured.in @@ -33,6 +33,7 @@ set_default("memprof_shadow_scale", "@COMPILER_RT_MEMPROF_SHADOW_SCALE@") set_default("apple_platform", "osx") set_default("apple_platform_min_deployment_target_flag", "-mmacosx-version-min") set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@) +set_default("sanitizer_uses_static_cxxabi", @SANITIZER_USE_STATIC_CXX_ABI_PYBOOL@) set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@) set_default("can_symbolize", @CAN_SYMBOLIZE@) set_default("use_lld", @COMPILER_RT_TEST_USE_LLD_PYBOOL@) -- 2.7.4