diff --git a/src/debug.c b/src/debug.c index 74249ff51..1dd446f78 100644 --- a/src/debug.c +++ b/src/debug.c @@ -55,6 +55,7 @@ * dump + 1. Only used when USE_THREAD_DUMP is set. */ volatile unsigned int thread_dump_state = 0; +unsigned int panic_started = 0; unsigned int debug_commands_issued = 0; /* dumps a backtrace of the current thread that is appended to buffer . @@ -337,6 +338,14 @@ static int debug_parse_cli_show_libs(char **args, char *payload, struct appctx * /* dumps a state of all threads into the trash and on fd #2, then aborts. */ void ha_panic() { + if (HA_ATOMIC_FETCH_ADD(&panic_started, 1) != 0) { + /* a panic dump is already in progress, let's not disturb it, + * we'll be called via signal DEBUGSIG. By returning we may be + * able to leave a current signal handler (e.g. WDT) so that + * this will ensure more reliable signal delivery. + */ + return; + } chunk_reset(&trash); chunk_appendf(&trash, "Thread %u is about to kill the process.\n", tid + 1); ha_thread_dump_all_to_trash();