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 <rusty@rustcorp.com.au>
This commit is contained in:
@@ -32,6 +32,9 @@ void send_backtrace(const char *why)
|
|||||||
if (backtrace_state)
|
if (backtrace_state)
|
||||||
backtrace_print(backtrace_state, 0, stderr);
|
backtrace_print(backtrace_state, 0, stderr);
|
||||||
|
|
||||||
|
if (!bt_print)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Now send to parent. */
|
/* Now send to parent. */
|
||||||
bt_print("%s (version %s)", why, version());
|
bt_print("%s (version %s)", why, version());
|
||||||
if (backtrace_state)
|
if (backtrace_state)
|
||||||
@@ -75,7 +78,8 @@ static void crashdump(int sig)
|
|||||||
send_backtrace(why);
|
send_backtrace(why);
|
||||||
|
|
||||||
/* Probably shouldn't return. */
|
/* Probably shouldn't return. */
|
||||||
bt_exit();
|
if (bt_exit)
|
||||||
|
bt_exit();
|
||||||
|
|
||||||
/* This time it will kill us instantly. */
|
/* This time it will kill us instantly. */
|
||||||
kill(getpid(), sig);
|
kill(getpid(), sig);
|
||||||
|
|||||||
Reference in New Issue
Block a user