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