aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/panic.go
diff options
context:
space:
mode:
authorNicolas Hillegeer <aktau@google.com>2024-02-08 08:56:33 -0800
committerGopher Robot <gobot@golang.org>2024-02-10 00:14:50 +0000
commit20f4b6d8f910adb5a3739dce5f4ffcfd2eb491c4 (patch)
tree363adef72c43b896e27b60a28f28a5f4f1450d64 /src/runtime/panic.go
parent2dfc5eae2ee177d44f867783e13d7401b9f34a18 (diff)
downloadgo-20f4b6d8f910adb5a3739dce5f4ffcfd2eb491c4.tar.xz
runtime: call traceAdvance before exiting
This ensures the trace buffers are as up-to-date as possible right before crashing. It increases the chance of finding the culprit for the crash when looking at core dumps, e.g. if slowness is the cause for the crash (monitor kills process). Fixes #65319. Change-Id: Iaf5551911b3b3b01ba65cb8749cf62a411e02d9c Reviewed-on: https://go-review.googlesource.com/c/go/+/562616 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/panic.go')
-rw-r--r--src/runtime/panic.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/runtime/panic.go b/src/runtime/panic.go
index e6d1c5d908..99eb1c3e23 100644
--- a/src/runtime/panic.go
+++ b/src/runtime/panic.go
@@ -759,6 +759,16 @@ func gopanic(e any) {
fn()
}
+ // If we're tracing, flush the current generation to make the trace more
+ // readable.
+ //
+ // TODO(aktau): Handle a panic from within traceAdvance more gracefully.
+ // Currently it would hang. Not handled now because it is very unlikely, and
+ // already unrecoverable.
+ if traceEnabled() {
+ traceAdvance(false)
+ }
+
// ran out of deferred calls - old-school panic now
// Because it is unsafe to call arbitrary user code after freezing
// the world, we call preprintpanics to invoke all necessary Error