]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: report haproxy and operating system info in panic dumps
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2025 13:21:23 +0000 (15:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2025 15:18:29 +0000 (17:18 +0200)
The goal is to help figure the OS version (kernel and userland), any
virtualization/containers, and the haproxy version and build features.
Sometimes even reporters themselve can be mistaken about the running
version or environment. Also printing this at the top hepls draw a
visual delimitation between warnings and panic. Now we get something
like this:

  PANIC! Thread 1 is about to kill the process.

  HAProxy info:
    version: 3.3-dev3-c863c0-18
    features: +51DEGREES +ACCEPT4 +BACKTRACE -CLOSEFROM +CPU_AFFINITY (...)

  Operating system info:
    virtual machine: no
    container: no
    kernel: Linux 6.1.131 #1 SMP PREEMPT_DYNAMIC Fri Mar 14 01:04:55 CET 2025 x86_64
    userland: Slackware 15.0 x86_64

  * Thread 1 : id=0x7f615a8775c0 act=1 glob=0 wq=1 rq=0 tl=0 tlsz=0 rqsz=0
        1/1    stuck=0 prof=0 harmless=0 isolated=0
               cpu_ns: poll=1835010197 now=1835066102 diff=55905
               (...)

src/debug.c

index bbd63bf9cd035eff00db98b8411a363676401bf8..eb6089c8c4234cde3ed45c4d857d80a5ee56b791 100644 (file)
@@ -771,7 +771,26 @@ void ha_panic()
                return;
        }
 
-       chunk_printf(&trash, "Thread %u is about to kill the process.\n", tid + 1);
+       chunk_printf(&trash, "\nPANIC! Thread %u is about to kill the process.\n", tid + 1);
+
+       /* dump a few of the post-mortem info */
+       chunk_appendf(&trash, "\nHAProxy info:\n  version: %s\n  features: %s\n",
+                     haproxy_version, build_features);
+
+       chunk_appendf(&trash, "\nOperating system info:\n");
+       if (*post_mortem.platform.virt_techno)
+               chunk_appendf(&trash, "  virtual machine: %s\n", post_mortem.platform.virt_techno);
+       if (*post_mortem.platform.cont_techno)
+               chunk_appendf(&trash, "  container: %s\n", post_mortem.platform.cont_techno);
+       if (*post_mortem.platform.utsname.sysname || *post_mortem.platform.utsname.release ||
+           *post_mortem.platform.utsname.version || *post_mortem.platform.utsname.machine)
+               chunk_appendf(&trash, "  kernel: %s %s %s %s\n",
+                             post_mortem.platform.utsname.sysname, post_mortem.platform.utsname.release,
+                             post_mortem.platform.utsname.version, post_mortem.platform.utsname.machine);
+       if (*post_mortem.platform.distro)
+               chunk_appendf(&trash, "  userland: %s\n", post_mortem.platform.distro);
+
+       chunk_appendf(&trash, "\n");
        DISGUISE(write(2, trash.area, trash.data));
 
        for (thr = 0; thr < global.nbthread; thr++) {