Linux core dumps - fordsfords/fordsfords.github.io GitHub Wiki
(sigh)
It used to be so simple. Your C program generates a segv, and leaves a "core" file in the current directory. Then it got a little more complicated (and better) by appending the PID to the file name.
Now finding a core file requires special wizard knowledge and I swear every freaking Linux system out there is different.
CentOS
What are we using?
$ sysctl kernel.core_pattern
kernel.core_pattern = |/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t %P %I %h %e
Abrt.
SIMPLIFY!
$ egrep kernel.core_pattern /etc/sysctl.conf
$ # if found, edit it. Else:
$ sudo echo "kernel.core_pattern=core.%p" >>/etc/sysctl.conf
$ sudo sysctl kernel.core_pattern=core.%p
WSL2 Ubuntu
cat /proc/sys/kernel/core_pattern
For WSL2 Ubuntu, I created the file ".wslconfig" file in the Windows home:
[wsl2]
# disable storing core files in C:\Users\fords\AppData\Local\Temp\wsl-crashes
maxCrashDumpCount=1
See https://github.com/microsoft/WSL/issues/11997#issuecomment-2353721025
Add "ulimit -c unlimited" to ".bashrc"
Then as root:
echo "kernel.core_pattern = core.%p" > /etc/sysctl.d/50-coredump.conf
systemctl disable apport
Then exit all shells and in a command tool enter:
wsl --shutdown
Abrt
RedHat 6/7/8
It looks like "reporting" and "autoreporting" are related to reporting problems to RedHat for distro programs.
https://abrt.readthedocs.io/en/latest/usage.html
To collect core dumps from unpackaged software (such as in-house developed applications), do the following:
- Edit /etc/abrt/abrt-action-save-package-data.conf
- Change ProcessUnpackaged to yes.
$ abrt-cli list
id dd6161e27332612a1ac5b05702664a39cbc0effe
reason: lbmmrcv killed by SIGABRT
time: Sun Mar 3 17:57:25 2024
cmdline: ./lbmmrcv -q -s -R30
uid: 2667 (sford)
count: 3
Directory: /var/spool/abrt/ccpp-2024-03-03-17:57:25-2053896
id 39ff32ab4b6d6977b8bc9643664acdfa65df376d
reason: .annobin_top_check.start(): minsrc killed by SIGABRT
time: Mon Sep 25 21:35:30 2023
cmdline: ./minsrc transport_tcp_port 12003
uid: 2667 (sford)
count: 1
Directory: /var/spool/abrt/ccpp-2023-09-25-21:35:30-3845145
Note that an ID can have a count > 1.
$ abrt-cli info -d /var/spool/abrt/ccpp-2024-03-03-17:57:25-2053896 >x
$ wc x
396 1075 12094 x
To get the core file:
sudo cat /var/spool/abrt/ccpp-2024-03-03-17:57:25-2053896/coredump >coredump