MINOR: debug: report haproxy and operating system info in panic dumps

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
               (...)
This commit is contained in:
Willy Tarreau 2025-07-15 15:21:23 +02:00
parent abcc73830f
commit 110625bdb2

View 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++) {