xref: /illumos-gate/usr/src/man/man5/core.5 (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1'\"
2.\" Copyright (C) 2008, Sun Microsystems, Inc. All Rights Reserved.
3.\" Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
4.\" Copyright (c) 2013, Joyent, Inc. All rights reserved.
5.\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
6.\" Copyright 2024 Oxide Computer Company
7.\" Copyright 1989 AT&T
8.\"
9.\" The contents of this file are subject to the terms of the
10.\" Common Development and Distribution License (the "License").
11.\" You may not use this file except in compliance with the License.
12.\"
13.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14.\" or http://www.opensolaris.org/os/licensing.
15.\" See the License for the specific language governing permissions
16.\" and limitations under the License.
17.\"
18.\" When distributing Covered Code, include this CDDL HEADER in each
19.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20.\" If applicable, add the following below this CDDL HEADER, with the
21.\" fields enclosed by brackets "[]" replaced with your own identifying
22.\" information: Portions Copyright [yyyy] [name of copyright owner]
23.\"
24.Dd May 10, 2024
25.Dt CORE 5
26.Os
27.Sh NAME
28.Nm core
29.Nd process core file
30.Sh DESCRIPTION
31The operating system writes out a core file for a process when the process is
32terminated due to receiving certain signals.
33A core file is a disk copy of the contents of the process address space at the
34time the process received the signal, along with additional information about
35the state of the process.
36This information can be consumed by a debugger.
37Core files can also be generated by applying the
38.Xr gcore 1
39utility to a running process.
40.Pp
41Typically, core files are produced following abnormal termination of a process
42resulting from a bug in the corresponding application.
43Whatever the cause, the core file itself provides invaluable information to the
44programmer or support engineer to aid in diagnosing the problem.
45The core file can be inspected using a debugger such as
46.Xr mdb 1 ,
47gdb, dbx, or  or by applying one of the
48.Xr proc 1
49tools.
50.Pp
51The operating system attempts to create up to two core files for each
52abnormally terminating process, using a global core file name pattern and a
53per-process core file name pattern.
54These patterns are expanded to determine the pathname of the resulting core
55files, and can be configured by
56.Xr coreadm 8 .
57By default, the global core file pattern is disabled and not used, and the
58per-process core file pattern is set to
59.Sy core .
60Therefore, by default, the operating system attempts to create a core file named
61.Pa core
62in the process's current working directory.
63.Pp
64A process terminates and produces a core file whenever it receives one of the
65signals whose default disposition is to cause a core dump or the
66.Xr upanic 2
67system call is used.
68The list of signals that result in generating a core file is shown in
69.Xr signal.h 3HEAD .
70Therefore, a process might not produce a core file if it has blocked or
71modified the behavior of the corresponding signal.
72Additionally, no core dump can be created under the following conditions:
73.Bl -bullet
74.It
75If normal file and directory access permissions prevent the creation or
76modification of the per-process core file pathname by the current process user
77and group ID.
78This test does not apply to the global core file pathname because, regardless of
79the UID of the process dumping core, the attempt to write the global core file
80is made as the superuser.
81.It
82Core files owned by the user
83.Sy nobody
84will not be produced.
85For example, core files generated for the superuser on an NFS directory are
86owned by
87.Sy nobody
88and are, therefore, not written.
89.It
90If the core file pattern expands to a pathname that contains intermediate
91directory components that do not exist.
92For example, if the global pattern is set to
93.Pa /var/core/%n/core.%p ,
94and no directory
95.Pa /var/core/`uname -n`
96has been created, no global core files are produced.
97.It
98If the destination directory is part of a filesystem that is mounted read-only.
99.It
100If the resource limit
101.Dv RLIMIT_CORE
102has been set to
103.Sy 0
104for the
105process, no per-process core file is produced.
106Refer to
107.Xr setrlimit 2
108and
109.Xr ulimit 1
110for more information on resource limits.
111.It
112If the core file name already exists in the destination directory and is not a
113regular file
114.Pq that is, is a symlink, block or character special-file, and so forth .
115.It
116If the kernel cannot open the destination file
117.Dv O_EXCL ,
118which can occur if same file is being created by another process simultaneously.
119.It
120If the process's effective user ID is different from its real user ID or if its
121effective group ID is different from its real group ID.
122Similarly, set-user-ID and set-group-ID programs do not produce core files as
123this could potentially compromise system security.
124These processes can be explicitly granted permission to produce core files using
125.Xr coreadm 8 ,
126at the risk of exposing secure information.
127.El
128.Pp
129The core file contains all the process information pertinent to debugging:
130contents of hardware registers, process status, and process data.
131The format of a core file is object file specific.
132.Pp
133For ELF executable programs
134.Po
135see
136.Xr a.out 5
137.Pc ,
138the core file generated is also an ELF file, containing ELF program and file
139headers.
140The
141.Fa e_type
142field in the file header has type
143.Dv ET_CORE .
144The program header contains an entry for every segment that was part of the
145process address space, including shared library segments.
146The contents of the mappings specified by
147.Xr coreadm 8
148are also part of the core image.
149Each program header has its
150.Fa p_memsz
151field set to the size of the mapping.
152The program headers that represent mappings whose data is included in the core
153file have their
154.Fa p_filesz
155field set the same as
156.Fa p_memsz ,
157otherwise
158.Fa p_filesz
159is
160.Sy zero .
161.Pp
162A mapping's data can be excluded due to the core file content settings
163.Po
164see
165.Xr coreadm 8
166.Pc ,
167due to a failure, or due to a signal received after core dump initiation but
168before its completion.
169If the data is excluded because of a failure, the program header entry will
170have the
171.Dv PF_SUNW_FAILURE
172flag set in its
173.Fa p_flags
174field; if the data is excluded because of a signal, the segment's
175.Fa p_flags
176field will have the
177.Dv PF_SUNW_KILLED
178flag set.
179.Pp
180The program headers of an
181.Sy ELF
182core file also contain entries for two
183.Sy NOTE
184segments, each containing several note entries as described below.
185The note entry header and core file note type
186.Pq Fa n_type
187definitions are contained in
188.In sys/elf.h .
189The first
190.Sy NOTE
191segment exists for binary compatibility with old programs that deal with core
192files.
193It contains structures defined in
194.In sys/old_procfs.h .
195New programs should recognize and skip this
196.Sy NOTE
197segment, advancing instead to the new
198.Sy NOTE
199segment.
200The old
201.Sy NOTE
202segment is deleted from core files in a future release.
203.Pp
204The old
205.Sy NOTE
206segment contains the following entries.
207Each has entry name
208.Sy "CORE"
209and presents the contents of a system structure:
210.Bl -tag -width prpsinfo_t
211.It Vt prpsinfo_t
212.Fa n_type :
213.Dv NT_PRPSINFO .
214This entry contains information of interest to the
215.Xr ps 1
216command, such as process status, CPU usage, nice value, controlling terminal,
217user-ID, process-ID, the name of the executable, and so forth.
218The
219.Vt prpsinfo_t
220structure is defined in
221.In sys/old_procfs.h .
222.It Vt char[]
223.Fa n_type :
224.Dv NT_PLATFORM .
225This entry contains a string describing the specific model of the hardware
226platform on which this core file was created.
227This information is the same as provided by
228.Xr sysinfo 2
229when invoked with the command
230.Dv SI_PLATFORM .
231.It Vt auxv_t[]
232.Fa n_type :
233.Dv NT_AUXV .
234This entry contains the array of
235.Vt Bauxv_t
236structures that was passed by the operating system as startup information to
237the dynamic linker.
238Auxiliary vector information is defined in
239.In sys/auxv.h .
240.El
241.Pp
242Following these entries, for each active (non-zombie) light-weight process
243.Pq LWP
244in the process, the old
245.Sy NOTE
246segment contains an entry with a
247.Vt prstatus_t
248structure, plus other optionally-present entries describing the LWP, as follows:
249.Bl -tag -width "prfpregset_t"
250.It Vt prstatus_t
251.Fa n_type :
252.Dv NT_PRSTATUS .
253This structure contains things of interest to a debugger from the operating
254system, such as the general registers, signal dispositions, state, reason for
255stopping, process-ID, and so forth.
256The
257.Vt prstatus_t
258structure is defined in
259.In sys/old_procfs.h .
260.It Vt prfpregset_t
261.Fa n_type :
262.Dv NT_PRFPREG .
263This entry is present only if the
264.Sy LWP
265used the floating-point hardware.
266It contains the floating-point registers.
267The
268.Vt prfpregset_t
269structure is defined in
270.In sys/procfs_isa.h .
271.It Vt gwindows_t
272.Fa n_type :
273.Dv NT_GWINDOWS .
274This entry is present only on a SPARC machine and only if the system was unable
275to flush all of the register windows to the stack.
276It contains all of the unspilled register windows.
277The
278.Vt gwindows_t
279structure is defined in
280.In sys/regset.h .
281.It Vt prxregset_t
282.Fa n_type :
283.Dv NT_PRXREG .
284This entry is no longer included in core files, but is of historical note
285because in the past it was included on SPARC-based systems.
286While since then the
287.Vt prxregset_t
288and extended register sets have been defined on other architectures, they do not
289emit this in the old note section because there is no binary compatibility.
290.El
291.Pp
292The new
293.Sy NOTE
294segment contains the following entries.
295Each has entry name
296.Sy "CORE"
297and presents the contents of a system structure:
298.Bl -tag -width prxregset_t
299.It Vt psinfo_t
300.Fa n_type :
301.Dv NT_PSINFO .
302This structure contains information of interest to the
303.Xr ps 1
304command, such as process status, CPU usage, nice value, controlling terminal,
305user-ID, process-ID, the name of the executable, and so forth.
306The
307.Vt psinfo_t
308structure is defined in
309.In sys/procfs.h
310.It Vt pstatus_t
311.Fa n_type :
312.Dv NT_PSTATUS .
313This structure contains things of interest to a debugger from the operating
314system, such as pending signals, state, process-ID, and so forth.
315The
316.Vt pstatus_t
317structure is defined in
318.In sys/procfs.h .
319.It Vt char[]
320.Fa n_type :
321.Dv NT_PLATFORM .
322This entry contains a string describing the specific model of the hardware
323platform on which this core file was created.
324This information is the same as provided by
325.Xr sysinfo 2
326when invoked with the command
327.Dv SI_PLATFORM .
328.It Vt auxv_t[]
329.Fa n_type :
330.Dv NT_AUXV .
331This entry contains the array of
332.Vt auxv_t
333structures that was passed by the operating system as startup information to
334the dynamic linker.
335Auxiliary vector information is defined in
336.In sys/auxv.h .
337.It Vt struct utsname
338.Fa n_type :
339.Dv NT_UTSNAME .
340This structure contains the system information that would have been returned
341to the process if it had performed a
342.Xr uname 2
343system call prior to dumping core.
344The
345.Vt utsname
346structure is defined in
347.In sys/utsname.h .
348.It Vt pcred_t
349.Fa n_type :
350.Dv NT_PRCRED .
351This structure contains the process credentials, including the real, saved,
352and effective user and group IDs.
353The
354.Vt pcred_t
355structure is defined in
356.In sys/procfs.h .
357Following the structure is an optional array of supplementary group IDs.
358The total number of supplementary group IDs is given by the
359.Fa pr_ngroups
360member of the
361.Vt pcred_t
362structure, and the structure includes space for one supplementary group.
363If
364.Fa pr_ngroups
365is greater than 1, there is
366.So
367.Fa pr_ngroups
368- 1
369.Sc
370.Fa gid_t
371items following the structure; otherwise, there is no additional data.
372.It Vt char[]
373.Fa n_type :
374.Dv NT_ZONENAME .
375This entry contains a string which describes the name of the zone in
376which the process was running.
377See
378.Xr zones 7 .
379The information is the same as provided by
380.Xr getzonenamebyid 3C
381when invoked with the numerical ID returned by
382.Xr getzoneid 3C .
383.It Vt prfdinfo_core_t
384.Fa n_type :
385.Dv NT_FDINFO .
386This structure contains information about any open file descriptors, including
387the path, flags, and
388.Xr stat 2
389information.
390The
391.Vt prfdinfo_core_t
392structure is defined in
393.In sys/procfs.h .
394.It Vt struct ssd[]
395.Fa n_type :
396.Dv NT_LDT .
397This entry is present only on an 32-bit x86 machine and only if the process has
398set up a Local Descriptor Table
399.Pq LDT .
400It contains an array of structures of type
401.Vt struct ssd ,
402each of which was typically used to set up the
403.Sy %gs
404segment register to be used to fetch the address of the current thread
405information structure in a multithreaded process.
406The
407.Vt ssd
408structure is defined in
409.In sys/sysi86.h .
410.It Vt core_content_t
411.Fa n_type :
412.Dv NT_CONTENT .
413This optional entry indicates which parts of the process image are specified
414to be included in the core file.
415See
416.Xr coreadm 8 .
417.It Vt prsecflags_t
418.Fa n_type :
419.Dv NT_SECFLAGS .
420This entry contains the process security-flags, see
421.Xr security-flags 7 ,
422.Xr proc 5 ,
423and
424.Xr psecflags 1
425for more information.
426.It Vt prupanic_t
427.Fa n_type :
428.Dv NT_UPANIC .
429This entry is included if a process terminated through the
430.Xr upanic 2
431system call.
432It is defined in
433.In sys/procfs.h .
434.Pp
435The
436.Fa pru_version
437member indicates the current revision of the structure, which is expected to be
438.Dv PRUPANIC_VERSION_1
439.Pq 1 .
440The
441.Fa pru_flags
442member will be set to the bitwise-inclusive-OR of the following fields:
443.Bl -tag -offset indent -width PRUPANIC_FLAG_MSG_TRUNC
444.It Dv PRUPANIC_FLAG_MSG_VALID
445Indicates that
446.Fa pru_data
447member has valid contents and that the process provided a message in the
448.Xr upanic 2
449call .
450.It Dv PRUPANIC_FLAG_MSG_ERROR
451Indicates that the calling process attempted to include a message; however, the
452provided address of the message did not point to valid memory.
453.It Dv PRUPANIC_FLAG_MSG_TRUNC
454Indicates that the calling process included a message; however, the message it
455wanted to provide was larger than the current message length.
456.El
457The
458.Fa pru_data
459array contains binary data that the terminating process used to indicate that
460the reason why it panicked.
461This member should be ignored if the
462.Dv PRUPANIC_FLAG_MSG_VALID
463flag is not set in
464.Fa pru_flags .
465While it is recommended that processes terminate with an ASCII string, consumers
466of this should not assume that the binary data is made of of printable
467characters.
468.It Vt prcwd_t
469.Fa n_type :
470.Dv NT_CWD .
471This entry describes information about the current working directory of the
472process at the time the core file is generated and information about the file
473system that the current working directory is found on.
474The
475.Vt prcwd_t
476is defined in
477.In sys/procfs.h .
478.Pp
479The members of the
480.Vt prcwd_t
481include:
482.Bl -tag -offset indent -width prcwd_mntspec
483.It Fa prcwd_fsid
484The file system ID.
485This is the same data that is found in the
486.Fa f_fsid
487member of the
488.Vt "struct statvfs"
489structure obtained through
490.Xr statvfs 2 .
491The file system ID is currently the device number
492.Po
493i.e. the
494.Vt dev_t
495.Pc
496and matches the
497.Fa mnt_major
498and
499.Fa mnt_minor
500of the
501.Vt "struct extmnttab"
502structure that is obtained through
503.Xr getextmntent 3C .
504.It Fa prcwd_fsname
505A NUL-terminated string containing the name of the file system itself, e.g.
506.Dq zfs ,
507.Dq tmpfs ,
508etc.
509This is the same as the
510.Fa f_bastype
511member of the
512.Vt "struct statvfs"
513and
514.Vt "mnt_fstype"
515of the
516.Vt "struct mnttab" .
517.It Fa prcwd_mntpt
518A NUL-terminated string that contains the path where the file system containing
519the current working directory is mounted.
520.It Fa prcwd_mntspec
521A NUL-terminated string that is the name of the mounted resource.
522This may be a ZFS dataset, a synthetic resource like
523.Dq swap ,
524.Dq procfs ,
525or
526.Dq bootfs ,
527or the path to a particular disk or file.
528This corresponds to the
529.Fa mnt_special
530member of the
531.Vt "struct mnttab" .
532.It Fa prcwd_cwd
533A NUL-terminated string containing the current path of the process at the time
534the core file was generated.
535.El
536.Pp
537From the operating system's perspective, a path is often just a NUL-terminated
538collection of bytes.
539This means it is possible that a path may contain bytes that are not printable
540or meaningful in the locale of a process that is processing this particular
541structure.
542.El
543.Pp
544For each active and zombie
545.Sy LWP
546in the process,
547the new
548.Sy NOTE
549segment contains an entry with an
550.Vt lwpsinfo_t
551structure plus, for a non-zombie LWP, an entry with an
552.Vt lwpstatus_t
553structure, plus other optionally-present entries describing the LWP, as follows.
554A zombie LWP is a non-detached LWP that has terminated but has not yet been
555reaped by another LWP in the same process.
556.Bl -tag -width "prxregset_t"
557.It Vt lwpsinfo_t
558.Fa n_type :
559.Dv NT_LWPSINFO .
560This structure contains information of interest to the
561.Xr ps 1
562command, such as LWP status, CPU usage, nice value, LWP-ID, and so forth.
563The
564.Vt lwpsinfo_t
565structure is defined in
566.In sys/procfs.h .
567This is the only entry present for a zombie LWP.
568.It lwpstatus_t
569.Fa n_type :
570.Dv NT_LWPSTATUS .
571This structure contains things of interest to a debugger from the operating
572system, such as the general registers, the floating point registers, state,
573reason for stopping, LWP-ID, and so forth.
574The
575.Vt lwpstatus_t
576structure is defined in
577.In sys/procfs.h .
578.Vt gwindows_t
579.Fa n_type :
580.Dv NT_GWINDOWS .
581This entry is present only on a SPARC machine and only if the system was unable
582to flush all of the register windows to the stack.
583It contains all of the unspilled register windows.
584The
585.Vt gwindows_t
586structure is defined in
587.In sys/regset.h .
588.It Vt prxregset_t
589.Fa n_type :
590.Dv NT_PRXREG .
591This entry is present only if the machine has extra register state associated
592with it.
593It contains the extra register state.
594The
595.Vt prxregset_t
596structure is defined in
597.In sys/procfs_isa.h ;
598however applications should include
599.In procfs.h
600to get access to it.
601On most architectures the
602.Vt prxregset_t
603is opaque and of variable size.
604.Xr proc 5
605discusses the structure of the extended register set for each supported
606architecture.
607.It Vt asrset_t
608\fB\fBasrset_t\fR\fR
609.Fa n_type :
610.Dv NT_ASRS .
611This entry is present only on a SPARC V9 machine and only if the process is a
61264-bit process.
613It contains the ancillary state registers for the LWP.
614The
615.Vt asrset_t asrset_t
616structure is defined in
617.In sys/regset.h .
618.It Vt psinfo_t
619.Fa n_type :
620.Dv NT_SPYMASTER .
621This entry is present only for an agent LWP and contains the
622.Vt psinfo_t
623of the process that created the agent LWP.
624See the
625.Xr proc 5
626description of the
627.Sy spymaster
628entry for more details.
629.El
630.Pp
631Depending on the
632.Xr coreadm 8
633settings, the section header of an ELF core file can contain entries for CTF,
634DWARF debug information, symbol table, and string table sections.
635The
636.Fa sh_addr
637fields are set to the base address of the first mapping of the load object that
638they came from to.
639This can be used to match those sections with the corresponding load object.
640.Pp
641The size of the core file created by a process can be controlled by the user
642.Po
643see
644.Xr getrlimit 2
645.Pc
646.Sh SEE ALSO
647.Xr elfdump 1 ,
648.Xr gcore 1 ,
649.Xr mdb 1 ,
650.Xr proc 1 ,
651.Xr ps 1 ,
652.Xr getrlimit 2 ,
653.Xr setrlimit 2 ,
654.Xr setuid 2 ,
655.Xr statvfs 2 ,
656.Xr sysinfo 2 ,
657.Xr uname 2 ,
658.Xr upanic 2 ,
659.Xr getextmntent 3C ,
660.Xr getzoneid 3C ,
661.Xr getzonenamebyid 3C ,
662.Xr elf 3ELF ,
663.Xr signal.h 3HEAD ,
664.Xr a.out 5 ,
665.Xr proc 5 ,
666.Xr security-flags 7 ,
667.Xr zones 7 ,
668.Xr coreadm 8
669