From 6cb107452a5a5551a04baf6bc4ff0b8299dfb596 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 24 Sep 2024 15:11:54 -0700 Subject: 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 Reviewed-by: Michael Pratt Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI --- src/runtime/panic.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/runtime/panic.go') 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. -- cgit v1.3-5-g9baa