aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/panic.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2024-09-24 15:11:54 -0700
committerGopher Robot <gobot@golang.org>2024-09-25 15:13:19 +0000
commit6cb107452a5a5551a04baf6bc4ff0b8299dfb596 (patch)
tree1d767f7dd2a6d7209c70980f4929ffaa8d086bf8 /src/runtime/panic.go
parentb17a55d0953429c9b23ef89407734ac9bba159f5 (diff)
downloadgo-6cb107452a5a5551a04baf6bc4ff0b8299dfb596.tar.xz
runtime: print fatal messages without interleaving
Grab the print lock around the set of prints we use to report fatal errors. This ensures that each fatal error gets reported atomically instead of interleaved with other fatal errors. Fixes #69447 Change-Id: Ib3569f0c8210fd7e19a7d8ef4bc114f07469f317 Reviewed-on: https://go-review.googlesource.com/c/go/+/615655 Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/panic.go')
-rw-r--r--src/runtime/panic.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/panic.go b/src/runtime/panic.go
index 5b62e019d9..d70d567912 100644
--- a/src/runtime/panic.go
+++ b/src/runtime/panic.go
@@ -1081,6 +1081,7 @@ func throw(s string) {
func fatal(s string) {
// Everything fatal does should be recursively nosplit so it
// can be called even when it's unsafe to grow the stack.
+ printlock() // Prevent multiple interleaved fatal reports. See issue 69447.
systemstack(func() {
print("fatal error: ")
printindented(s) // logically printpanicval(s), but avoids convTstring write barrier
@@ -1088,6 +1089,7 @@ func fatal(s string) {
})
fatalthrow(throwTypeUser)
+ printunlock()
}
// runningPanicDefers is non-zero while running deferred functions for panic.