aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/panic.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2022-07-14 17:36:59 -0400
committerMichael Pratt <mpratt@google.com>2022-08-12 01:38:55 +0000
commitbd302502d39b6172bf3db6abfa49fdcaa124ee50 (patch)
tree3b5ad6d467a4f529f8416d6989c880a7f28d27d7 /src/runtime/panic.go
parent7666ec1c99b2f8c88b42fb5462510cafce120a6f (diff)
downloadgo-bd302502d39b6172bf3db6abfa49fdcaa124ee50.tar.xz
runtime: convert panicking to atomic type
For #53821. Change-Id: I93409f377881a3c029b41b0f1fbcef5e21091f2f Reviewed-on: https://go-review.googlesource.com/c/go/+/419438 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime/panic.go')
-rw-r--r--src/runtime/panic.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/runtime/panic.go b/src/runtime/panic.go
index a3e676fea4..4fadbfc2e0 100644
--- a/src/runtime/panic.go
+++ b/src/runtime/panic.go
@@ -1071,8 +1071,7 @@ func fatal(s string) {
var runningPanicDefers atomic.Uint32
// panicking is non-zero when crashing the program for an unrecovered panic.
-// panicking is incremented and decremented atomically.
-var panicking uint32
+var panicking atomic.Uint32
// paniclk is held while printing the panic information and stack trace,
// so that two concurrent panics don't overlap their output.
@@ -1209,7 +1208,7 @@ func startpanic_m() bool {
case 0:
// Setting dying >0 has the side-effect of disabling this G's writebuf.
gp.m.dying = 1
- atomic.Xadd(&panicking, 1)
+ panicking.Add(1)
lock(&paniclk)
if debug.schedtrace > 0 || debug.scheddetail > 0 {
schedtrace(true)
@@ -1272,7 +1271,7 @@ func dopanic_m(gp *g, pc, sp uintptr) bool {
}
unlock(&paniclk)
- if atomic.Xadd(&panicking, -1) != 0 {
+ if panicking.Add(-1) != 0 {
// Some other m is panicking too.
// Let it print what it needs to print.
// Wait forever without chewing up cpu.