table of contents
- bookworm 252.31-1~deb12u1
- bookworm-backports 254.16-1~bpo12+1
- testing 256.7-3
- unstable 257~rc2-3
SYSTEMD-COREDUMP(8) | systemd-coredump | SYSTEMD-COREDUMP(8) |
NAME¶
systemd-coredump, systemd-coredump.socket, systemd-coredump@.service - Acquire, save and process core dumps
SYNOPSIS¶
/usr/lib/systemd/systemd-coredump
/usr/lib/systemd/systemd-coredump --backtrace
systemd-coredump@.service
systemd-coredump.socket
DESCRIPTION¶
systemd-coredump@.service is a system service to process core dumps. It will log a summary of the event to systemd-journald.service(8), including information about the process identifier, owner, the signal that killed the process, and the stack trace if possible. It may also save the core dump for later processing. See the "Information about the crashed process" section below.
The behavior of a specific program upon reception of a signal is governed by a few factors which are described in detail in core(5). In particular, the core dump will only be processed when the related resource limits are sufficient.
Core dumps can be written to the journal or saved as a file. In both cases, they can be retrieved for further processing, for example in gdb(1). See coredumpctl(1), in particular the list and debug verbs.
By default, systemd-coredump will log the core dump to the journal, including a backtrace if possible, and store the core dump (an image of the memory contents of the process) itself in an external file in /var/lib/systemd/coredump. These core dumps are deleted after a few days by default; see /usr/lib/tmpfiles.d/systemd.conf for details. Note that the removal of core files from the file system and the purging of journal entries are independent, and the core file may be present without the journal entry, and journal entries may point to since-removed core files. Some metadata is attached to core files in the form of extended attributes, so the core files are useful for some purposes even without the full metadata available in the journal entry.
For further details see systemd Coredump Handling[1].
Invocation of systemd-coredump¶
The systemd-coredump executable does the actual work. It is invoked twice: once as the handler by the kernel, and the second time in the systemd-coredump@.service to actually write the data to the journal and process and save the core file.
When the kernel invokes systemd-coredump to handle a core dump, it runs in privileged mode, and will connect to the socket created by the systemd-coredump.socket unit, which in turn will spawn an unprivileged systemd-coredump@.service instance to process the core dump. Hence systemd-coredump.socket and systemd-coredump@.service are helper units which do the actual processing of core dumps and are subject to normal service management.
It is also possible to invoke systemd-coredump with --backtrace option. In this case, systemd-coredump expects a journal entry in the journal Journal Export Format[2] on standard input. The entry should contain a MESSAGE= field and any additional metadata fields the caller deems reasonable. systemd-coredump will append additional metadata fields in the same way it does for core dumps received from the kernel. In this mode, no core dump is stored in the journal.
CONFIGURATION¶
For programs started by systemd, process resource limits can be set by directive LimitCORE=, see systemd.exec(5).
In order to be used by the kernel to handle core dumps, systemd-coredump must be configured in sysctl(8) parameter kernel.core_pattern. The syntax of this parameter is explained in core(5). systemd installs the file /usr/lib/sysctl.d/50-coredump.conf which configures kernel.core_pattern accordingly. This file may be masked or overridden to use a different setting following normal sysctl.d(5) rules. If the sysctl configuration is modified, it must be updated in the kernel before it takes effect, see sysctl(8) and systemd-sysctl(8).
In order to be used in the --backtrace mode, an appropriate backtrace handler must be installed on the sender side. For example, in case of python(1), this means a sys.excepthook must be installed, see systemd-coredump-python[3].
The behavior of systemd-coredump itself is configured through the configuration file /etc/systemd/coredump.conf and corresponding snippets /etc/systemd/coredump.conf.d/*.conf, see coredump.conf(5). A new instance of systemd-coredump is invoked upon receiving every core dump. Therefore, changes in these files will take effect the next time a core dump is received.
Resources used by core dump files are restricted in two ways. Parameters like maximum size of acquired core dumps and files can be set in files /etc/systemd/coredump.conf and snippets mentioned above. In addition the storage time of core dump files is restricted by systemd-tmpfiles, corresponding settings are by default in /usr/lib/tmpfiles.d/systemd.conf. The default is to delete core dumps after a few days; see the above file for details.
Disabling coredump processing¶
To disable potentially resource-intensive processing by systemd-coredump, set
Storage=none ProcessSizeMax=0
in coredump.conf(5).
INFORMATION ABOUT THE CRASHED PROCESS¶
coredumpctl(1) can be used to retrieve saved core dumps independently of their location, to display information, and to process them e.g. by passing to the GNU debugger (gdb).
Data stored in the journal can be also viewed with journalctl(1) as usual (or from any other process, using the sd-journal(3) API). The relevant messages have MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1:
$ journalctl MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1 -o verbose ... MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1 COREDUMP_PID=552351 COREDUMP_UID=1000 COREDUMP_GID=1000 COREDUMP_SIGNAL_NAME=SIGSEGV COREDUMP_SIGNAL=11 COREDUMP_TIMESTAMP=1614342930000000 COREDUMP_COMM=Web Content COREDUMP_EXE=/usr/lib64/firefox/firefox COREDUMP_USER_UNIT=app-gnome-firefox-552136.scope COREDUMP_CMDLINE=/usr/lib64/firefox/firefox -contentproc -childID 5 -isForBrowser ... COREDUMP_CGROUP=/user.slice/user-1000.slice/user@1000.service/app.slice/app-....scope COREDUMP_FILENAME=/var/lib/systemd/coredump/core.Web....552351.....zst ...
The following fields are saved (if known) with the journal entry
COREDUMP_UID=, COREDUMP_PID=, COREDUMP_GID=
When the crashed process was part of a container (or in a process or user namespace in general), those are the values as seen outside, in the namespace where systemd-coredump is running.
Added in version 248.
COREDUMP_TIMESTAMP=
Added in version 248.
COREDUMP_RLIMIT=
Added in version 248.
COREDUMP_UNIT=, COREDUMP_SLICE=
When the crashed process was in container, those are the units names outside, in the main system manager.
Added in version 248.
COREDUMP_CGROUP=
When the crashed process was in a container, this is the full path, as seen outside of the container.
Added in version 248.
COREDUMP_PROC_CGROUP=
When the crashed process was in a container, this is the full path, as seen outside of the container.
Added in version 248.
COREDUMP_OWNER_UID=, COREDUMP_USER_UNIT=, COREDUMP_SESSION=
When the crashed process was in container, those are the values outside, in the main system.
Added in version 248.
COREDUMP_SIGNAL_NAME=, COREDUMP_SIGNAL=
Added in version 248.
COREDUMP_CWD=, COREDUMP_ROOT=
When the crashed process is in a container, those paths are relative to the root of the container's mount namespace.
Added in version 248.
COREDUMP_OPEN_FDS=
fd:/path/to/file pos: ... flags: ... ... fd:/path/to/file pos: ... flags: ... ...
The first line contains the file descriptor number fd and the path, while subsequent lines show the contents of /proc/pid/fdinfo/fd.
Added in version 248.
COREDUMP_EXE=
When the crashed process is in a container, that path is relative to the root of the container's mount namespace.
Added in version 248.
COREDUMP_CMDLINE=, COREDUMP_COMM=, COREDUMP_ENVIRON=, COREDUMP_PROC_AUXV=, COREDUMP_PROC_LIMITS=, COREDUMP_PROC_MAPS=, COREDUMP_PROC_MOUNTINFO=, COREDUMP_PROC_STATUS=
See proc(5) for more information.
Added in version 248.
COREDUMP_HOSTNAME=
When the crashed process was in container, this is the container hostname.
Added in version 248.
COREDUMP_CONTAINER_CMDLINE=
Added in version 248.
COREDUMP=
Added in version 248.
COREDUMP_FILENAME=
Added in version 248.
COREDUMP_TRUNCATED=
Added in version 248.
COREDUMP_PACKAGE_NAME=, COREDUMP_PACKAGE_VERSION=, COREDUMP_PACKAGE_JSON=
Added in version 249.
MESSAGE=
Added in version 248.
Various other fields exist in the journal entry, but pertain to the logging process, i.e. systemd-coredump, not the crashed process. See systemd.journal-fields(7).
The following fields are saved (if known) with the external file listed in COREDUMP_FILENAME= as extended attributes:
user.coredump.pid, user.coredump.uid, user.coredump.gid, user.coredump.signal, user.coredump.timestamp, user.coredump.rlimit, user.coredump.hostname, user.coredump.comm, user.coredump.exe
Added in version 248.
Those can be viewed using getfattr(1). For the core file described in the journal entry shown above:
$ getfattr --absolute-names -d /var/lib/systemd/coredump/core.Web....552351.....zst # file: /var/lib/systemd/coredump/core.Web....552351.....zst user.coredump.pid="552351" user.coredump.uid="1000" user.coredump.gid="1000" user.coredump.signal="11" user.coredump.timestamp="1614342930000000" user.coredump.comm="Web Content" user.coredump.exe="/usr/lib64/firefox/firefox" ...
SEE ALSO¶
coredump.conf(5), coredumpctl(1), systemd-journald.service(8), systemd-tmpfiles(8), core(5), sysctl.d(5), systemd-sysctl.service(8), systemd Coredump Handling[1]
NOTES¶
- 1.
- systemd Coredump Handling
- 2.
- Journal Export Format
- 3.
- systemd-coredump-python
systemd 256.7 |