From 89ca5aef9fbfe751bd1b4fa9213dee82612e9dd8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 23 Jan 2025 09:38:29 +1030 Subject: [PATCH] common: don't crash on send_backtrace() if bt_print is NULL. This (and bt_exit) are NULL for libplugin. We don't always want to crash! Signed-off-by: Rusty Russell --- common/daemon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/daemon.c b/common/daemon.c index 31878a55d..c14de8b07 100644 --- a/common/daemon.c +++ b/common/daemon.c @@ -32,6 +32,9 @@ void send_backtrace(const char *why) if (backtrace_state) backtrace_print(backtrace_state, 0, stderr); + if (!bt_print) + return; + /* Now send to parent. */ bt_print("%s (version %s)", why, version()); if (backtrace_state) @@ -75,7 +78,8 @@ static void crashdump(int sig) send_backtrace(why); /* Probably shouldn't return. */ - bt_exit(); + if (bt_exit) + bt_exit(); /* This time it will kill us instantly. */ kill(getpid(), sig);