]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: print gdb hints when crashing
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Jun 2024 12:04:46 +0000 (14:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Jun 2024 05:43:00 +0000 (07:43 +0200)
To make bug reporting easier for users, when crashing, let's suggest
what to do. Typically when a BUG_ON() matches, only the current thread
is useful the vast majority of the time, while when the watchdog
triggers, all threads are interesting.

The messages are printed at the end after the dump. We may adjust these
with wiki links in the future is more detailed instructions are relevant.

include/haproxy/bug.h
src/debug.c

index b89ed22247cd806aa66d7c66c5484707e40e226a..f43dbad2b4f2e8f8ec5c2d6c7e3a18dd291bcfb0 100644 (file)
@@ -123,9 +123,16 @@ static __attribute__((noinline,noreturn,unused)) void abort_with_line(uint line)
 }
 
 #define __ABORT_NOW(file, line, ...) do {                              \
+               extern ssize_t write(int, const void *, size_t);        \
+               const char *msg;                                        \
                if (sizeof("" __VA_ARGS__) > 1)                         \
                        complain(NULL, "\nABORT at " file ":" #line ": " __VA_ARGS__ "\n", 1); \
                DUMP_TRACE();                                           \
+               msg = "\n"                                              \
+                     "Hint: when reporting this bug to developers, please check if a core file was\n" \
+                     "      produced, open it with 'gdb', issue 'bt' to produce a backtrace for the\n" \
+                     "      current thread only, then join it with the bug report.\n"; \
+               DISGUISE(write(2, msg, strlen(msg)));                   \
                abort_with_line(__LINE__);                              \
        } while (0)
 #else
@@ -133,9 +140,16 @@ static __attribute__((noinline,noreturn,unused)) void abort_with_line(uint line)
  * stack and stops at the exact location we need.
  */
 #define __ABORT_NOW(file, line, ...) do {                              \
+               extern ssize_t write(int, const void *, size_t);        \
+               const char *msg;                                        \
                if (sizeof("" __VA_ARGS__) > 1)                         \
                        complain(NULL, "\nABORT at " file ":" #line ": " __VA_ARGS__ "\n", 1); \
                DUMP_TRACE();                                           \
+               msg = "\n"                                              \
+                     "Hint: when reporting this bug to developers, please check if a core file was\n" \
+                     "      produced, open it with 'gdb', issue 'bt' to produce a backtrace for the\n" \
+                     "      current thread only, then join it with the bug report.\n"; \
+               DISGUISE(write(2, msg, strlen(msg)));                   \
                ha_crash_now();                                         \
        } while (0)
 #endif
index 522c78af58624044179c7b505cb74a0bcaafacaf..dfd44f5a2a4732713072f810e8dd27d82bdb7bfb 100644 (file)
@@ -680,6 +680,15 @@ void ha_panic()
                DISGUISE(write(2, trash.area, trash.data));
        }
 
+       chunk_printf(&trash,
+                    "\n"
+                    "Hint: when reporting this bug to developers, please check if a core file was\n"
+                    "      produced, open it with 'gdb', issue 't a a bt full', check that the\n"
+                    "      output does not contain sensitive data, then join it with the bug report.\n"
+                    "      For more info, please see https://github.com/haproxy/haproxy/issues/2374\n");
+
+       DISGUISE(write(2, trash.area, trash.data));
+
        for (;;)
                abort();
 }