2018-07-03 05:15:39 +08:00
|
|
|
<?xml version='1.0'?>
|
2019-03-14 21:40:58 +08:00
|
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
2020-11-09 12:23:58 +08:00
|
|
|
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
2014-07-14 08:32:46 +08:00
|
|
|
|
|
|
|
<refentry id="systemd-coredump" conditional='ENABLE_COREDUMP'
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
|
|
|
|
<refentryinfo>
|
|
|
|
<title>systemd-coredump</title>
|
|
|
|
<productname>systemd</productname>
|
|
|
|
</refentryinfo>
|
|
|
|
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>systemd-coredump</refentrytitle>
|
|
|
|
<manvolnum>8</manvolnum>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>systemd-coredump</refname>
|
2016-04-06 09:00:10 +08:00
|
|
|
<refname>systemd-coredump.socket</refname>
|
|
|
|
<refname>systemd-coredump@.service</refname>
|
2016-05-16 17:56:04 +08:00
|
|
|
<refpurpose>Acquire, save and process core dumps</refpurpose>
|
2014-07-14 08:32:46 +08:00
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
2015-06-19 01:47:44 +08:00
|
|
|
<para><filename>/usr/lib/systemd/systemd-coredump</filename></para>
|
2016-11-06 23:48:15 +08:00
|
|
|
<para><filename>/usr/lib/systemd/systemd-coredump</filename> <option>--backtrace</option></para>
|
2016-04-06 09:00:10 +08:00
|
|
|
<para><filename>systemd-coredump@.service</filename></para>
|
|
|
|
<para><filename>systemd-coredump.socket</filename></para>
|
2014-07-14 08:32:46 +08:00
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
2021-02-28 02:00:51 +08:00
|
|
|
<para><filename>systemd-coredump@.service</filename> is a system service to process core dumps. It will
|
|
|
|
log a summary of the event to
|
|
|
|
<citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
|
|
|
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.</para>
|
2014-07-14 08:32:46 +08:00
|
|
|
|
2016-05-16 17:56:04 +08:00
|
|
|
<para>The behavior of a specific program upon reception of a signal is governed by a few
|
|
|
|
factors which are described in detail in
|
|
|
|
<citerefentry project='man-pages'><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
|
|
|
In particular, the core dump will only be processed when the related resource limits are sufficient.
|
2016-04-02 22:40:09 +08:00
|
|
|
</para>
|
2016-11-06 23:48:15 +08:00
|
|
|
|
2021-02-28 02:00:51 +08:00
|
|
|
<para>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
|
|
|
|
<citerefentry project='man-pages'><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
|
|
|
|
See <citerefentry><refentrytitle>coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
|
|
|
in particular the <command>list</command> and <command>debug</command> verbs.</para>
|
|
|
|
|
|
|
|
<para>By default, <command>systemd-coredump</command> 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 <filename>/var/lib/systemd/coredump</filename>. These core dumps are deleted after a
|
|
|
|
few days by default; see <filename>/usr/lib/tmpfiles.d/systemd.conf</filename> 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. Metadata is attached to core files in the form of extended attributes, so the core files may be
|
|
|
|
useful even without the full metadata available in the journal entry.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<refsect2>
|
|
|
|
<title>Invocation of <command>systemd-coredump</command></title>
|
|
|
|
|
|
|
|
<para>The <command>systemd-coredump</command> executable does the actual work. It is invoked twice:
|
|
|
|
once as the handler by the kernel, and the second time in the
|
|
|
|
<filename>systemd-coredump@.service</filename> to actually write the data to the journal and process
|
|
|
|
and save the core file.</para>
|
|
|
|
|
|
|
|
<para>When the kernel invokes <command>systemd-coredump</command> to handle a core dump, it runs in
|
|
|
|
privileged mode, and will connect to the socket created by the
|
|
|
|
<filename>systemd-coredump.socket</filename> unit, which in turn will spawn an unprivileged
|
|
|
|
<filename>systemd-coredump@.service</filename> instance to process the core dump. Hence
|
|
|
|
<filename>systemd-coredump.socket</filename> and <filename>systemd-coredump@.service</filename> are
|
|
|
|
helper units which do the actual processing of core dumps and are subject to normal service
|
|
|
|
management.</para>
|
|
|
|
|
|
|
|
<para>It is also possible to invoke <command>systemd-coredump</command> with
|
|
|
|
<option>--backtrace</option> option. In this case, <command>systemd-coredump</command> expects a
|
|
|
|
journal entry in the journal
|
|
|
|
<ulink url="https://www.freedesktop.org/wiki/Software/systemd/export">Journal Export Format</ulink>
|
|
|
|
on standard input. The entry should contain a <varname>MESSAGE=</varname> field and any additional
|
|
|
|
metadata fields the caller deems reasonable. <command>systemd-coredump</command> 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.</para>
|
|
|
|
</refsect2>
|
2016-05-16 17:56:04 +08:00
|
|
|
</refsect1>
|
2016-04-02 23:05:11 +08:00
|
|
|
|
2016-05-16 17:56:04 +08:00
|
|
|
<refsect1>
|
|
|
|
<title>Configuration</title>
|
2020-11-23 20:21:46 +08:00
|
|
|
<para>For programs started by <command>systemd</command>, process resource limits can be set by directive
|
|
|
|
<varname>LimitCORE=</varname>, see
|
2016-05-16 17:56:04 +08:00
|
|
|
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
|
|
|
</para>
|
|
|
|
|
2016-11-06 23:48:15 +08:00
|
|
|
<para>In order to be used by the kernel to handle core dumps,
|
|
|
|
<command>systemd-coredump</command> must be configured in
|
2016-05-16 17:56:04 +08:00
|
|
|
<citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
|
|
|
parameter <varname>kernel.core_pattern</varname>. The syntax of this parameter is explained in
|
|
|
|
<citerefentry project='man-pages'><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
2017-12-14 00:42:04 +08:00
|
|
|
systemd installs the file <filename>/usr/lib/sysctl.d/50-coredump.conf</filename> which configures
|
2016-05-16 17:56:04 +08:00
|
|
|
<varname>kernel.core_pattern</varname> accordingly. This file may be masked or overridden to use a different
|
|
|
|
setting following normal
|
|
|
|
<citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
2016-11-06 23:48:15 +08:00
|
|
|
rules. If the sysctl configuration is modified, it must be updated in the kernel before it
|
|
|
|
takes effect, see
|
2016-05-16 17:56:04 +08:00
|
|
|
<citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
2016-04-02 23:05:11 +08:00
|
|
|
and
|
2016-05-16 17:56:04 +08:00
|
|
|
<citerefentry><refentrytitle>systemd-sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
|
2016-04-02 23:05:11 +08:00
|
|
|
</para>
|
2016-05-16 17:56:04 +08:00
|
|
|
|
2020-11-23 20:21:46 +08:00
|
|
|
<para>In order to be used in the <option>--backtrace</option> mode, an appropriate backtrace
|
2016-11-06 23:48:15 +08:00
|
|
|
handler must be installed on the sender side. For example, in case of
|
2017-05-07 23:29:40 +08:00
|
|
|
<citerefentry project='die-net'><refentrytitle>python</refentrytitle><manvolnum>1</manvolnum></citerefentry>, this
|
2020-11-23 20:21:46 +08:00
|
|
|
means a <varname>sys.excepthook</varname> must be installed, see
|
2016-11-06 23:48:15 +08:00
|
|
|
<ulink url="https://github.com/keszybz/systemd-coredump-python">systemd-coredump-python</ulink>.
|
|
|
|
</para>
|
|
|
|
|
2016-10-13 05:02:44 +08:00
|
|
|
<para>The behavior of <command>systemd-coredump</command> itself is configured through the configuration file
|
2016-05-16 17:56:04 +08:00
|
|
|
<filename>/etc/systemd/coredump.conf</filename> and corresponding snippets
|
|
|
|
<filename>/etc/systemd/coredump.conf.d/*.conf</filename>, see
|
|
|
|
<citerefentry><refentrytitle>coredump.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>. A new
|
|
|
|
instance of <command>systemd-coredump</command> is invoked upon receiving every core dump. Therefore, changes
|
|
|
|
in these files will take effect the next time a core dump is received.</para>
|
|
|
|
|
|
|
|
<para>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 <filename>/etc/systemd/coredump.conf</filename> and snippets mentioned
|
|
|
|
above. In addition the storage time of core dump files is restricted by <command>systemd-tmpfiles</command>,
|
2020-12-15 07:35:43 +08:00
|
|
|
corresponding settings are by default in <filename>/usr/lib/tmpfiles.d/systemd.conf</filename>. The default is
|
|
|
|
to delete core dumps after a few days; see the above file for details.</para>
|
2018-05-17 23:08:31 +08:00
|
|
|
|
|
|
|
<refsect2>
|
|
|
|
<title>Disabling coredump processing</title>
|
|
|
|
|
2021-02-28 02:00:51 +08:00
|
|
|
<para>To disable potentially resource-intensive processing by <command>systemd-coredump</command>, set
|
|
|
|
<programlisting>Storage=none ProcessSizeMax=0</programlisting> in
|
2018-05-17 23:08:31 +08:00
|
|
|
<citerefentry><refentrytitle>coredump.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
|
|
|
</para>
|
|
|
|
</refsect2>
|
2016-05-16 17:56:04 +08:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Usage</title>
|
|
|
|
<para>Data stored in the journal can be viewed with
|
2021-02-28 02:00:51 +08:00
|
|
|
<citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> as usual.
|
|
|
|
<citerefentry><refentrytitle>coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> can be
|
|
|
|
used to retrieve saved core dumps independent of their location, to display information and to process
|
2016-05-16 17:56:04 +08:00
|
|
|
them e.g. by passing to the GNU debugger (gdb).</para>
|
2014-07-14 08:32:46 +08:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
<para>
|
|
|
|
<citerefentry><refentrytitle>coredump.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
2016-05-16 17:56:04 +08:00
|
|
|
<citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
2014-07-14 08:32:46 +08:00
|
|
|
<citerefentry project='man-pages'><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>systemd-sysctl.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|