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