systemd-coredump, systemd-coredump.socket, systemd-coredump@.service, systemd-coredump-register.service, systemd-coredumpd.service — Acquire, save and process core dumps
/usr/lib/systemd/systemd-coredump
/usr/lib/systemd/systemd-coredump --backtrace
/usr/lib/systemd/systemd-coredump --manager
/usr/lib/systemd/systemd-coredump --check-requirements
systemd-coredump.socket
systemd-coredump@.service
systemd-coredump-register.service
systemd-coredumpd.service
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 process resource limits
(RLIMIT_CORE) 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.
The systemd-coredump executable does the actual work, but is invoked differently depending on the capabilities of the running kernel.
When the kernel supports the kernel coredump socket protocol (see "Kernel Requirements" below,
generally kernel v6.19 or newer), systemd-coredumpd.service creates and listens on
a Unix socket, and systemd-coredump-register.service writes the socket path to
/proc/sys/kernel/core_pattern. When a process crashes, the kernel connects to the
socket, and sends the core dump of the process through the socket. Then,
systemd-coredumpd.service transfers the core to the corresponding container if the
crashed process is in a container environment, otherwise saves the core in the local storage and writes
information about the crashed process to journal.
When the running kernel does not meet those requirements, the executable
systemd-coredump 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 this way, 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.
See "Units" below for details on the individual units involved in either mode.
systemd-coredump is normally not invoked directly by the user, but by the kernel, or by the units described below. It supports the following modes of invocation:
Handles a single core dump. This is the mode the kernel uses to invoke
systemd-coredump directly (via kernel.core_pattern) on
kernels that do not support the kernel coredump socket protocol, as well as the mode used by
systemd-coredump@.service to actually process and save a core dump that was
handed to it via systemd-coredump.socket.
--backtrace¶systemd-coredump expects a journal entry in the
Journal Export
Format 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.
--manager¶Runs systemd-coredump as the long-running manager process that
listens on the kernel coredump socket, accepts connections from the kernel, and forks off worker
processes to process each individual core dump. This is the mode used internally by
systemd-coredumpd.service and is not intended to be invoked interactively.
See "Units" below for details.
--check-requirements¶Checks whether the running kernel and execution environment fulfil the
requirements for the kernel coredump socket protocol (see "Kernel Requirements" below), and exits
with a non-zero status if they are not met. This is used internally as the
ExecCondition= of systemd-coredumpd.service and
systemd-coredump-register.service, so that those units are skipped, without
being marked as failed, on systems where the feature is unavailable. It is not intended to be
invoked interactively.
The kernel coredump socket protocol, used by systemd-coredumpd.service and
systemd-coredump-register.service, requires:
A kernel that supports the PIDFD_INFO_COREDUMP (since kernel
v6.16) and PIDFD_INFO_COREDUMP_SIGNAL (since kernel v6.19) flags for the
PIDFD_GET_INFO
ioctl(2)
operation on a PID file descriptor (see
pidfd_open(2)).
Support for these flags is used as an indicator that the kernel is also new enough to support the
request-mode ("@@"-prefixed) kernel coredump socket
kernel.core_pattern, which was introduced in kernel v6.17.
systemd-coredump must be running in the initial PID, USER, and TIME namespaces, i.e. on the host, not inside a container.
These conditions are checked with systemd-coredump
--check-requirements before systemd-coredumpd.service and
systemd-coredump-register.service are started. If the requirements are not met,
systemd-coredump instead falls back to the legacy invocation via
systemd-coredump.socket and systemd-coredump@.service.
The following units are involved in processing core dumps. Which of them are active depends on whether the kernel coredump socket protocol is available, see "Kernel Requirements" above.
systemd-coredumpd.service¶A long-running manager service, started early at boot on kernels that support the
kernel coredump socket protocol. It creates and listens on the AF_UNIX socket
/run/systemd/coredumpd/kernel (this path is also passed to the kernel via
kernel.core_pattern by systemd-coredump-register.service,
see below). When the kernel connects to this socket to submit a core dump,
systemd-coredumpd.service accepts the connection and forks off a worker
process to receive and process that specific core dump, up to a limit of 8 concurrently running
workers (once this limit is reached, no further connections are accepted until a worker finishes).
Workers that run for longer than 5 minutes are killed automatically.
The configuration in
coredump.conf(5)
is read once when systemd-coredumpd.service starts. Since the service keeps
running afterwards (rather than being invoked anew for every core dump, as
systemd-coredump@.service is), changes to
coredump.conf and its drop-ins are not picked up
automatically. Reload the service to apply configuration changes, see
coredump.conf(5)
for details.
systemd-coredump-register.service¶A oneshot unit, automatically pulled in and bound to the lifetime of
systemd-coredumpd.service (it is not meant to be started or stopped manually).
Once systemd-coredumpd.service is up, this unit points the kernel at it by
setting kernel.core_pattern to the request-mode ("@@"-prefixed)
socket path /run/systemd/coredumpd/kernel, and persists this setting to
/run/sysctl.d/60-coredump.conf via
systemd-sysctl(8).
When systemd-coredumpd.service is stopped,
systemd-coredump-register.service is stopped along with it and reverts
kernel.core_pattern to its previous value.
Because /run/sysctl.d/60-coredump.conf takes precedence, per the usual
sysctl.d(5)
ordering rules, over the /usr/lib/sysctl.d/50-coredump.conf file described in
"Configuration" below, masking or overriding 50-coredump.conf alone is
not sufficient to install a custom kernel.core_pattern on a
system where systemd-coredumpd.service is active. See "Configuration" below
for how to prevent this.
systemd-coredump.socket, systemd-coredump@.service¶Legacy handler units, used on kernels that do not support the kernel coredump
socket protocol (see "Kernel Requirements" above). The kernel invokes
systemd-coredump directly and in privileged mode for each crash; that instance
connects to systemd-coredump.socket, which in turn spawns an unprivileged
systemd-coredump@.service instance to actually process and save the core
dump. Unlike systemd-coredumpd.service, a fresh
systemd-coredump@.service instance is started for every core dump, so it
always reads the current coredump.conf configuration.
The systemd-coredump@.service service will automatically attempt to extract
a stacktrace from a process as it crashes. For this stacktrace symbols will be resolved based on debug
information embedded in the crashing ELF image, or equivalent debug information separately available on
the host OS. For processes that crash inside of local containers or other mount namespace-based
sandboxes, this auxiliary debug information is typically not available on the host (simply because
containers typically run different software versions than the
host). systemd-coredump provides two mechanisms to address this:
For full-OS containers running systemd inside it is a good idea to enable
CoredumpReceive= on the unit (see
systemd.resource-control(5)),
which ensures that coredumps of a container are attempted to be forwarded to
systemd-coredump@.service running inside the container, i.e the container gets
to process and store its own core dumps. Note that
systemd-nspawn(1)
defaults to this mode if invoked with the --boot switch. This mode of operation is
generally recommended for security reasons: the security-sensitive processing of the core dump is
done within the confinements of the container itself, by the container's own code, backed by the
container's own storage.
Alternatively, for more restricted containers (that do not run a proper
init system as PID 1) it is possible to enable processing of the core dump on
the host, with access to the debug information data from the container itself. This mode of operation
must be enabled via EnterNamespace= in
coredump.conf(5),
and defaults to off, for security reasons.
If both CoredumpReceive= is enabled on the unit of the container the core dump
belongs to, and EnterNamespace= is enabled in the coredump.conf
configuration file, the former takes precedence.
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).
On systems where systemd-coredumpd.service is active (see "Kernel
Requirements" and "Units" above), systemd-coredump-register.service writes its own
kernel.core_pattern setting to /run/sysctl.d/60-coredump.conf
whenever systemd-coredumpd.service is running, and this file takes precedence over
/usr/lib/sysctl.d/50-coredump.conf. As a result, masking or overriding
50-coredump.conf alone does not override the default
kernel.core_pattern on such systems, since 60-coredump.conf will
still take effect. To set a custom kernel.core_pattern of your own on a system where
systemd-coredumpd.service is active, stop and disable it:
systemctl disable --now systemd-coredumpd.service
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.
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). When
core dumps are processed via systemd-coredump@.service (see "Units" above), a new
instance of systemd-coredump is invoked upon receiving every core dump, and changes in
these files will take effect the next time a core dump is received. When core dumps are instead processed
by the long-running systemd-coredumpd.service, configuration changes require an
explicit reload of that service to take effect; see
coredump.conf(5) for
details.
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.
To disable potentially resource-intensive processing by systemd-coredump, set
Storage=none ProcessSizeMax=0
in coredump.conf(5).
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_CODE=2 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=¶The process number (PID), owner user number (UID), and group number (GID) of the crashed process.
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.
COREDUMP_BY_PIDFD=¶If the crashed process was analyzed using a PIDFD provided by the kernel (requires
kernel v6.16) then this field will be present and set to "1". If this field is
not set, then the crashed process was analyzed via a PID, which is known to be subject to race
conditions.
COREDUMP_TIMESTAMP=¶The time of the crash as reported by the kernel (in μs since the epoch).
COREDUMP_RLIMIT=¶The core file size soft resource limit, see getrlimit(2).
COREDUMP_UNIT=, COREDUMP_SLICE=¶The system unit and slice names.
When the crashed process was in container, those are the units names outside, in the main system manager.
COREDUMP_CGROUP=¶The primary cgroup of the unit of the crashed process.
When the crashed process was in a container, this is the full path, as seen outside of the container.
COREDUMP_PROC_CGROUP=¶Control group information in the format used in
/proc/self/cgroup. On systems with the unified cgroup hierarchy, this is a
single path prefixed with "0::", and multiple paths prefixed with controller numbers
on legacy systems.
When the crashed process was in a container, this is the full path, as seen outside of the container.
COREDUMP_OWNER_UID=, COREDUMP_USER_UNIT=, COREDUMP_SESSION=¶The numerical UID of the user owning the login session or systemd user unit of the crashed process, the user manager unit, and the session identifier. All three fields are only present for user processes.
When the crashed process was in container, those are the values outside, in the main system.
COREDUMP_SIGNAL_NAME=, COREDUMP_SIGNAL=¶The terminating signal name (with the "SIG" prefix
[1]) and numerical value. (Both are included because signal numbers vary by
architecture.)
COREDUMP_CODE=¶The reason why the signal was sent as a numerical value. The code is defined as
field si_code in the siginfo_t structure and
documented in sigaction(2).
COREDUMP_CWD=, COREDUMP_ROOT=¶The current working directory and root directory of the crashed process.
When the crashed process is in a container, those paths are relative to the root of the container's mount namespace.
COREDUMP_DUMPABLE=¶The PR_GET_DUMPABLE field as reported by the kernel, see
prctl(2).
COREDUMP_OPEN_FDS=¶Information about open file descriptors, in the following format:
fd:/path/to/filepos: ... flags: ... ...fd:/path/to/filepos: ... flags: ... ...
The first line contains the file descriptor number fd and the path,
while subsequent lines show the contents of
/proc/.
pid/fdinfo/fd
COREDUMP_EXE=¶The destination of the /proc/
symlink.pid/exe
When the crashed process is in a container, that path is relative to the root of the container's mount namespace.
COREDUMP_CMDLINE=, COREDUMP_COMM=, COREDUMP_ENVIRON=, COREDUMP_PROC_AUXV=, COREDUMP_PROC_LIMITS=, COREDUMP_PROC_MAPS=, COREDUMP_PROC_MOUNTINFO=, COREDUMP_PROC_STATUS=¶Fields that map the per-process entries in the /proc/
filesystem: /proc/ (the command line of
the crashed process), pid/cmdline/proc/ (the command
name associated with the process), pid/comm/proc/
(the environment block of the crashed process),
pid/environ/proc/ (the auxiliary vector of the crashed
process, see getauxval(3)),
pid/auxv/proc/ (the soft and hard resource limits),
pid/limits/proc/ (memory regions visible to the process
and their access permissions), pid/maps/proc/
(mount points in the process's mount namespace),
pid/mountinfo/proc/ (various metadata about the
process).pid/status
See proc(5) for more information.
COREDUMP_HOSTNAME=¶The system hostname.
When the crashed process was in container, this is the container hostname.
COREDUMP_CONTAINER_CMDLINE=¶For processes running in a container, the command line of the process spawning the container (the first parent process with a different mount namespace).
COREDUMP=¶When the core is stored in the journal, the core image itself.
COREDUMP_FILENAME=¶When the core is stored externally, the path to the core file.
COREDUMP_TRUNCATED=¶Set to "1" when the saved coredump was truncated. (A partial core
image may still be processed by some tools, though obviously not all information is available.)
COREDUMP_PACKAGE_NAME=, COREDUMP_PACKAGE_VERSION=, COREDUMP_PACKAGE_JSON=¶If the executable contained .package metadata ELF notes, they will be parsed and
attached. The package and version of the 'main' ELF module
(i.e., the executable) will be appended individually. The JSON-formatted content of all modules will
be appended as a single JSON object, each with the module name as the key. For more information about
this metadata format and content, see the
Package Metadata for Executable Files
document.
MESSAGE=¶The message generated by systemd-coredump that includes the
backtrace if it was successfully generated. When systemd-coredump is invoked with
--backtrace, this field is provided by the caller.
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¶Those are the same as COREDUMP_PID=,
COREDUMP_UID=, COREDUMP_GID=,
COREDUMP_SIGNAL=, COREDUMP_TIMESTAMP=,
COREDUMP_RLIMIT=, COREDUMP_HOSTNAME=,
COREDUMP_COMM=, and COREDUMP_EXE=, described above.
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" …