]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man5/core.5
tarfs.5: Document the importance of zstd framing
[FreeBSD/FreeBSD.git] / share / man / man5 / core.5
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .Dd November 12, 2023
29 .Dt CORE 5
30 .Os
31 .Sh NAME
32 .Nm core
33 .Nd memory image file format
34 .Sh SYNOPSIS
35 .In sys/param.h
36 .Sh DESCRIPTION
37 A small number of signals which cause abnormal termination of a process
38 also cause a record of the process's in-core state to be written
39 to disk for later examination by one of the available debuggers.
40 (See
41 .Xr sigaction 2 . )
42 This memory image is written to a file named by default
43 .Nm programname.core
44 in the working directory;
45 provided the terminated process had write permission in the directory,
46 and provided the abnormality did not cause
47 a system crash.
48 (In this event, the decision to save the core file is arbitrary, see
49 .Xr savecore 8 . )
50 .Pp
51 The maximum size of a core file is limited by the
52 .Dv RLIMIT_CORE
53 .Xr setrlimit 2
54 limit.
55 Files which would be larger than the limit are not created.
56 .Pp
57 With a large limit, a process that had mapped a very large,
58 and perhaps sparsely populated, virtual memory region, could take
59 a very long time to create core dumps.
60 The system ignores all signals sent to a process writing a core file, except
61 .Dv SIGKILL
62 which terminates the writing and causes immediate exit of the process.
63 The behavior of
64 .Dv SIGKILL
65 can be disabled by setting tunable
66 .Xr sysctl 8
67 variable
68 .Va kern.core_dump_can_intr
69 to zero.
70 .Pp
71 The name of the file is controlled via the
72 .Xr sysctl 8
73 variable
74 .Va kern.corefile .
75 The contents of this variable describes a filename to store
76 the core image to.
77 This filename can be absolute, or relative (which
78 will resolve to the current working directory of the program
79 generating it).
80 .Pp
81 The following format specifiers may be used in the
82 .Va kern.corefile
83 sysctl to insert additional information into the resulting core
84 filename:
85 .Bl -tag -width "1234567890" -compact -offset "12345"
86 .It Em \&%H
87 Machine hostname.
88 .It Em \&%I
89 An index starting at zero until the sysctl
90 .Em debug.ncores
91 is reached.
92 This can be useful for limiting the number of corefiles
93 generated by a particular process.
94 .It Em \&%N
95 process name.
96 .It Em \&%P
97 processes PID.
98 .It Em \&%S
99 signal during core.
100 .It Em \&%U
101 process UID.
102 .El
103 .Pp
104 The name defaults to
105 .Em \&%N.core ,
106 yielding the traditional
107 .Fx
108 behaviour.
109 .Pp
110 By default, a process that changes user or group credentials whether
111 real or effective will not create a corefile.
112 This behaviour can be
113 changed to generate a core dump by setting the
114 .Xr sysctl 8
115 variable
116 .Va kern.sugid_coredump
117 to 1.
118 .Pp
119 Corefiles can be compressed by the kernel if the following item
120 is included in the kernel configuration file:
121 .Bl -tag -width "1234567890" -compact -offset "12345"
122 .It options
123 GZIO
124 .El
125 .Pp
126 The following sysctl control core file compression:
127 .Bl -tag -width "kern.compress_user_cores_level" -compact -offset "12345"
128 .It Em kern.compress_user_cores
129 Enable compression of user cores.
130 A value of 1 configures
131 .Xr gzip 1
132 compression,
133 and a value of 2 configures
134 .Xr zstd 1
135 compression.
136 Compressed core files will have a suffix of
137 .Ql .gz
138 or
139 .Ql .zst
140 appended to their filenames depending on the selected format.
141 .It Em kern.compress_user_cores_level
142 Compression level.
143 Defaults to 6.
144 .El
145 .Sh NOTES
146 Corefiles are written with open file descriptor information as an ELF note.
147 By default, file paths are packed to only use as much space as needed.
148 However, file paths can change at any time, including during core dump,
149 and this can result in truncated file descriptor data.
150 .Pp
151 All file descriptor information can be preserved by disabling packing.
152 This potentially wastes up to PATH_MAX bytes per open fd.
153 Packing is disabled with
154 .Dl sysctl kern.coredump_pack_fileinfo=0 .
155 .Pp
156 Similarly, corefiles are written with vmmap information as an ELF note, which
157 contains file paths.
158 By default, they are packed to only use as much space as
159 needed.
160 By the same mechanism as for the open files note, these paths can also
161 change at any time and result in a truncated note.
162 .Pp
163 All vmmap information can be preserved by disabling packing.
164 Like the file information, this potentially wastes up to PATH_MAX bytes per
165 mapped object.
166 Packing is disabled with
167 .Dl sysctl kern.coredump_pack_vmmapinfo=0 .
168 .Sh EXAMPLES
169 In order to store all core images in per-user private areas under
170 .Pa /var/coredumps
171 (assuming the appropriate subdirectories exist and are writable by users),
172 the following
173 .Xr sysctl 8
174 command can be used:
175 .Pp
176 .Dl sysctl kern.corefile=/var/coredumps/\&%U/\&%N.core
177 .Sh SEE ALSO
178 .Xr gdb 1 Pq Pa ports/devel/gdb ,
179 .Xr gzip 1 ,
180 .Xr kgdb 1 Pq Pa ports/devel/gdb ,
181 .Xr setrlimit 2 ,
182 .Xr sigaction 2 ,
183 .Xr sysctl 8
184 .Sh HISTORY
185 A
186 .Nm
187 file format appeared in
188 .At v1 .