https://github.com/cachemeifyoucan created 
https://github.com/llvm/llvm-project/pull/196148

The EXPECT_DEATH calls in LibclangCrashTest.cpp can occasionally crash on
macOS CI with the following stack:

  Result: died but not with expected error.
    Expected: contains regular expression "ERROR"
  [ DEATH ]  0  libclangCrashTests       llvm::sys::PrintStackTrace
  [ DEATH ]  2  libclangCrashTests       SignalHandler
  [ DEATH ]  3  libsystem_platform.dylib _sigtramp
  [ DEATH ]  4  libsystem_trace.dylib    _os_log_find
  [ DEATH ]  5  libsystem_trace.dylib    os_log_create
  [ DEATH ]  6  libclang.dylib           llvm::SignpostEmitter::SignpostEmitter
  [ DEATH ]  7  libclang.dylib           llvm::TimerGlobals::TimerGlobals
  [ DEATH ] 13  libclang.dylib           clang::SourceManager::SourceManager

Switch both death-tests in LibclangCrashTest.cpp to the "threadsafe"
style, which re-execs the unit-test binary for the child and therefore
starts from a fresh libsystem_trace state. This matches the mitigation
applied to LLDB's MemoryDeathTest in cb6dd90d2871 / #181127.

rdar://176052229


>From 5ec9eeb7b7b4734badaa3cb0937d144f942386f1 Mon Sep 17 00:00:00 2001
From: Steven Wu <[email protected]>
Date: Wed, 6 May 2026 11:45:49 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 .../libclang/CrashTests/LibclangCrashTest.cpp          | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/clang/unittests/libclang/CrashTests/LibclangCrashTest.cpp 
b/clang/unittests/libclang/CrashTests/LibclangCrashTest.cpp
index 26c63cfbd427b..5c606bfa291af 100644
--- a/clang/unittests/libclang/CrashTests/LibclangCrashTest.cpp
+++ b/clang/unittests/libclang/CrashTests/LibclangCrashTest.cpp
@@ -12,6 +12,11 @@
 #include <string>
 
 TEST_F(LibclangParseTest, InstallAbortingLLVMFatalErrorHandler) {
+  // gtest death-tests execute in a sub-process (fork), which invalidates
+  // any signpost handles and would cause spurious crashes if used. Use the
+  // "threadsafe" style of death-test to work around this.
+  GTEST_FLAG_SET(death_test_style, "threadsafe");
+
   clang_toggleCrashRecovery(0);
   clang_install_aborting_llvm_fatal_error_handler();
 
@@ -24,6 +29,11 @@ TEST_F(LibclangParseTest, 
InstallAbortingLLVMFatalErrorHandler) {
 }
 
 TEST_F(LibclangParseTest, UninstallAbortingLLVMFatalErrorHandler) {
+  // gtest death-tests execute in a sub-process (fork), which invalidates
+  // any signpost handles and would cause spurious crashes if used. Use the
+  // "threadsafe" style of death-test to work around this.
+  GTEST_FLAG_SET(death_test_style, "threadsafe");
+
   clang_toggleCrashRecovery(0);
   clang_install_aborting_llvm_fatal_error_handler();
   clang_uninstall_llvm_fatal_error_handler();

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to