From d2aad0df601df3a48ee4823309872cd224d91aa3 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 3 Dec 2025 15:42:03 -0500 Subject: [PATCH] runtime: guard unexpected return pc gp.m dereference If stack scanning reaches here while scanning a waiting goroutine, gp.m will be nil. We are going to crash anyway because the stack is corrupt, but we still want to reach the print below for context rather than dying with a SIGSEGV here. For #64030. Change-Id: I6a6a636c378669dc45972e1eb8e06401a0fed223 Reviewed-on: https://go-review.googlesource.com/c/go/+/726522 Auto-Submit: Michael Pratt LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek --- src/runtime/traceback.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 1c6f24c033..4fe0fd89e2 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -456,7 +456,7 @@ func (u *unwinder) next() { // get everything, so crash loudly. fail := u.flags&(unwindPrintErrors|unwindSilentErrors) == 0 doPrint := u.flags&unwindSilentErrors == 0 - if doPrint && gp.m.incgo && f.funcID == abi.FuncID_sigpanic { + if doPrint && gp.m != nil && gp.m.incgo && f.funcID == abi.FuncID_sigpanic { // We can inject sigpanic // calls directly into C code, // in which case we'll see a C -- 2.52.0