MINOR: debug: call backtrace() once upon startup
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Mar 2020 05:01:40 +0000 (06:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2020 15:09:20 +0000 (17:09 +0200)
Calling backtrace() will access libgcc at runtime. We don't want to do
it after the chroot, so let's perform a first call to have it ready in
memory for later use.

(cherry picked from commit 0214b45a61cd7cfd59d729b23f497a687192cde6)
Signed-off-by: Willy Tarreau <w@1wt.eu>

src/debug.c

index 4435fe3..bd9d6f3 100644 (file)
@@ -719,6 +719,14 @@ static int init_debug()
 {
        struct sigaction sa;
 
+#ifdef USE_BACKTRACE
+       /* calling backtrace() will access libgcc at runtime. We don't want to
+        * do it after the chroot, so let's perform a first call to have it
+        * ready in memory for later use.
+        */
+       void *callers[1];
+       backtrace(callers, sizeof(callers)/sizeof(*callers));
+#endif
        sa.sa_handler = NULL;
        sa.sa_sigaction = debug_handler;
        sigemptyset(&sa.sa_mask);