Skip to content

Commit 87d1aee

Browse files
Fedrclaude
andcommitted
Parser: install LLVM stack-trace signal handler in main
Install `llvm::sys::PrintStackTraceOnErrorSignal` at the top of `main()` so a `SIGSEGV` / Windows SEH `STATUS_ACCESS_VIOLATION` from inside libclang prints a backtrace to stderr instead of silently dying. Diagnostic-only — no behavior change on the happy path. With `RelWithDebInfo` builds (already the default per `install_mrbind_windows_msys2.bat`), mrbind frames carry DWARF source locations. libclang-cpp / libLLVM frames show function names only, because msys2 strips DLL debug info. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 878c8c2 commit 87d1aee

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/parser/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include <clang/Tooling/CommonOptionsParser.h>
4343
#include <clang/Tooling/Tooling.h>
4444
#include <llvm/Support/CommandLine.h>
45+
#include <llvm/Support/PrettyStackTrace.h>
46+
#include <llvm/Support/Signals.h>
4547
#include "post_include_clang.h"
4648

4749
#include <array>
@@ -3470,6 +3472,13 @@ namespace mrbind
34703472

34713473
int main(int raw_argc, char **raw_argv)
34723474
{
3475+
// Print a stack trace to stderr on SIGSEGV / SEH access violations.
3476+
// RelWithDebInfo builds keep DWARF symbols in mrbind.exe, so the mrbind
3477+
// frames in the trace are line-numbered. libclang-cpp.dll frames will
3478+
// only show function names (msys2 strips DLL debug info).
3479+
llvm::sys::PrintStackTraceOnErrorSignal(raw_argv[0]);
3480+
llvm::PrettyStackTraceProgram pretty_stack(raw_argc, raw_argv);
3481+
34733482
mrbind::SetErrorHandlers();
34743483

34753484
std::string dump_command_to_file;

0 commit comments

Comments
 (0)