[clang] [clang-repl]: Print stack-trace on crash (PR #117896)

Mészáros Gergely via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 27 07:42:33 PST 2024


https://github.com/Maetveis created https://github.com/llvm/llvm-project/pull/117896

Call `llvm::sys::PrintStackTraceOnErrorSignal` at the start of main to
1. Print a strack trace on crash
2. Disable the assertion failed popup in Windows Debug Builds

Other tools (for example clang-check or clang-query) already do this.

This fixes debug build bots hanging (waiting for the popup to be dismissed) and ultimately getting terminated due to timeout. See https://lab.llvm.org/buildbot/#/builders/81/builds/2646/steps/6/logs/stdio for an example of the hang

>From 50b6510eba22c2111705e4fc815f4d63f2b7249e Mon Sep 17 00:00:00 2001
From: Gergely Meszaros <gergely.meszaros at intel.com>
Date: Wed, 27 Nov 2024 07:20:43 -0800
Subject: [PATCH] [clang-repl]: Print stack-trace on crash

Call `llvm::sys::PrintStackTraceOnErrorSignal` at the start of main to
1. Print a strack trace on crash
2. Disable the assertion failed popup in Windows Debug Builds

Other tools (for example clang-check or clang-query) already do this.

This fixes debug build bots hanging (waiting for the popup to be dismissed)
and ultimately getting terminated due to timeout.
---
 clang/tools/clang-repl/ClangRepl.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp
index 08c54e6cafa901..7af8e4f25d99e7 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -139,6 +139,8 @@ ReplListCompleter::operator()(llvm::StringRef Buffer, size_t Pos,
 
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+
   ExitOnErr.setBanner("clang-repl: ");
   llvm::cl::ParseCommandLineOptions(argc, argv);
 



More information about the cfe-commits mailing list