Search code examples
linuxdebiancoredumpdebian-stretch

Enabling core dumps on Debian 9


I've noticed my Debian 9 VM doesn't create a core dump with kill -s 6 <pid>. Looked into ulimit, suid_dumpable, core_pattern - they seem OK to me. The message after kill doesn't show (core dumped), and there is no core file in either the working directory or the one specified in core_pattern. Sudo doesn't help. Any configuration piece I'm missing?

Configuration:

   Static hostname: <hostname>
         Icon name: computer-vm
           Chassis: vm
        Machine ID: <redacted>
           Boot ID: <redacted>
    Virtualization: microsoft
  Operating System: Debian GNU/Linux 9 (stretch)
            Kernel: Linux 4.19.128-dcc08d126b2b
      Architecture: x86-64
<user>@<hostname>:~$ ulimit -Ha
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 56048
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1048576
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 56048
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
<user>@<hostname>:~$ ulimit -Sa
core file size          (blocks, -c) 100000
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 56048
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 56048
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
<user>@<hostname>:~$ cat /proc/sys/fs/suid_dumpable
1
<user>@<hostname>:~$ cat /proc/sys/kernel/core_pattern
/opt/core/%e.SIG-%s.%p.core

Example:

<user>@<hostname>:~$ sleep 500 &
[1] 14259
<user>@<hostname>:~$ kill -s 6 14259
[1]+  Aborted                 sleep 500
<user>@<hostname>:~$ ls -la /opt/core/
total 8
drwxr-xr-x 2 root root 4096 Jun  8 15:27 .
drwxr-xr-x 6 root root 4096 Jun  8 15:27 ..
<user>@<hostname>:~$ ls -la | grep core
<user>@<hostname>:~$

Solution

  • Maybe your system has been messed by systemd. In that case you have to install systemd-coredump:

    # apt-get install systemd-coredump 
    

    Next you can inspect the core dumps with coredumpctl.

    # sleep 100
    ^\Quit (core dumped)
    # coredumpctl list
    TIME                            PID   UID   GID SIG COREFILE  EXE
    Tue 2021-06-15 18:00:58 CEST  21065     0     0   3 present   /bin/sleep
    

    They are placed in /var/lib/systemd/coredump.

    # ll /var/lib/systemd/coredump/
    total 68
    -rw-r----- 1 root root 26605 Jun 15 18:00 core.sleep.0.af2fa0f571f84f279c4510ee3281a787.21065.1623772857000000.lz4