aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-05-24 09:33:45 -0400
committerGopher Robot <gobot@golang.org>2024-05-24 16:41:13 +0000
commitf85c40438fea862be03d2de4b58ed3afe7cfe033 (patch)
tree199325218768f9bd674f77dcfe9f3312ecff164f /src/runtime/proc.go
parent378c48df3b485da1ed287f59e5d1f59ad232e554 (diff)
downloadgo-f85c40438fea862be03d2de4b58ed3afe7cfe033.tar.xz
internal/runtime/exithook: make safe for concurrent os.Exit
Real programs can call os.Exit concurrently from multiple goroutines. Make internal/runtime/exithook not crash in that case. The throw on panic also now runs in the deferred context, so that we will see the full stack trace that led to the panic. That should give us more visibility into the flaky failures on bugs #55167 and #56197 as well. Fixes #67631. Change-Id: Iefdf71b3a3b52a793ca88d89a9c270eb50ece094 Reviewed-on: https://go-review.googlesource.com/c/go/+/588235 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index c5bf537a75..17b2e4d9c2 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -310,10 +310,14 @@ func os_beforeExit(exitCode int) {
}
}
+func init() {
+ exithook.Gosched = Gosched
+ exithook.Goid = func() uint64 { return getg().goid }
+ exithook.Throw = throw
+}
+
func runExitHooks(code int) {
- if err := exithook.Run(code); err != nil {
- throw(err.Error())
- }
+ exithook.Run(code)
}
// start forcegc helper goroutine