Skip to content

Commit d453942

Browse files
committed
MDEV-28884: include kernel information in crashing signal handler
Recent adventures in liburing and btrfs have shown up some kernel version dependent bugs. Having a bug report of accurace kernel version can start to correlate these errors sooner. On Linux, /proc/version contains the kernel version. FreeBSD has kern.version (per man 8 sysctl), so include that too. Example output: Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us Core pattern: |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h Kernel version: Linux version 5.19.0-0.rc2.21.fc37.x86_64 (mockbuild@bkernel01.iad2.fedoraproject.org) (gcc (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1), GNU ld version 2.38-14.fc37) #1 SMP PREEMPT_DYNAMIC Mon Jun 13 15:27:24 UTC 2022 Segmentation fault (core dumped)
1 parent f299351 commit d453942

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sql/signal_handler.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ static inline void output_core_info()
8181
my_safe_printf_stderr("Core pattern: %.*s\n", (int) len, buff);
8282
my_close(fd, MYF(0));
8383
}
84+
if ((fd= my_open("/proc/version", O_RDONLY, MYF(0))) >= 0)
85+
{
86+
len= my_read(fd, (uchar*)buff, sizeof(buff), MYF(0));
87+
my_safe_printf_stderr("Kernel version: %.*s\n", (int) len, buff);
88+
my_close(fd, MYF(0));
89+
}
8490
#endif
8591
#elif defined(__APPLE__) || defined(__FreeBSD__)
8692
char buff[PATH_MAX];
@@ -89,6 +95,10 @@ static inline void output_core_info()
8995
{
9096
my_safe_printf_stderr("Core pattern: %.*s\n", (int) len, buff);
9197
}
98+
if (sysctlbyname("kern.version", buff, &len, NULL, 0) == 0)
99+
{
100+
my_safe_printf_stderr("Kernel version: %.*s\n", (int) len, buff);
101+
}
92102
#else
93103
char buff[80];
94104
my_getwd(buff, sizeof(buff), 0);

0 commit comments

Comments
 (0)