xref: /netbsd-src/share/man/man9/panic.9 (revision 4b075bd22c61b9a6a08d29bd622e75c503611487)
1.\"     $NetBSD: panic.9,v 1.23 2019/10/04 21:55:00 gutteridge Exp $
2.\"
3.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" Michael Graff.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd October 4, 2019
31.Dt PANIC 9
32.Os
33.Sh NAME
34.Nm panic
35.Nd bring down system on fatal error
36.Sh SYNOPSIS
37.In sys/types.h
38.In sys/systm.h
39.Ft void
40.Fn vpanic "const char *fmt" "va_list ap"
41.Ft void
42.Fn panic "const char *fmt" "..."
43.Sh DESCRIPTION
44The
45.Fn panic
46and
47.Fn vpanic
48functions terminate the
49.Nx
50system.
51The message
52.Fa fmt
53is a
54.Xr printf 3
55style format string which is printed to the console and saved in the
56variable
57.Va panicstr
58for later retrieval via core dump inspection.
59A newline character is added at the end automatically, and is thus
60not needed in the format string.
61.Pp
62If a kernel debugger is installed, control is passed to it after the
63message is printed.
64If the kernel debugger is
65.Xr ddb 4 ,
66control may be passed to it, depending on the value of
67.Em ddb.onpanic .
68See
69.Xr options 4
70for more details on setting
71.Em ddb.onpanic .
72If control is not passed through to
73.Xr ddb 4 ,
74a
75.Xr ddb 4 Ns -specific
76function is used to print the kernel stack trace, and then control returns
77to
78.Fn panic .
79.Pp
80If control remains in
81.Fn panic ,
82an attempt is made to save an image of system memory on the
83configured dump device.
84.Pp
85If during the process of handling the panic,
86.Fn panic
87is called again
88.Pq from the filesystem synchronization routines, for example ,
89the system is rebooted immediately without synchronizing any filesystems.
90.Pp
91.Fn panic
92is meant to be used in situations where something unexpected has happened
93and it is difficult to recover the system to a stable state, or in
94situations where proceeding might make things worse, leading to data
95corruption and/or loss.
96It is not meant to be used in scenarios where the system could easily
97ignore and/or isolate the condition/subsystem and proceed.
98.Pp
99In general developers should try to reduce the number of
100.Fn panic
101calls in the kernel to improve stability.
102.Sh RETURN VALUES
103The
104.Fn panic
105function never returns.
106.Sh SEE ALSO
107.Xr printf 3 ,
108.Xr sysctl 3 ,
109.Xr ddb 4 ,
110.Xr options 4 ,
111.Xr savecore 8 ,
112.Xr swapctl 8 ,
113.Xr sysctl 8 ,
114.Xr printf 9
115