From cf3d253c1b6d61cff9e1ba2425c0a8bddbd8af0e Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 1 Dec 2023 21:05:34 +0000 Subject: [PATCH] runtime: check if mp.curg is nil before readgstatus in writeProcStatusForP CL 546025 failed to check if mp.curg is nil, causing all sorts of failures. It can very well be nil in this context. For #64318. Fixes #64507. Change-Id: I4a95c3fa16d5e1dee8041394c4bdb9c6ba04f032 Reviewed-on: https://go-review.googlesource.com/c/go/+/546636 Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI --- src/runtime/trace2status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/trace2status.go b/src/runtime/trace2status.go index c4a0eced8c..a4a8905196 100644 --- a/src/runtime/trace2status.go +++ b/src/runtime/trace2status.go @@ -88,7 +88,7 @@ func (w traceWriter) writeProcStatusForP(pp *p, inSTW bool) traceWriter { // but it still owns the P (it's not in _Psyscall yet). The goroutine entering // _Gsyscall is the tracer's signal that the P its bound to is also in a syscall, // so we need to emit a status that matches. See #64318. - if w.mp.p.ptr() == pp && readgstatus(w.mp.curg)&^_Gscan == _Gsyscall { + if w.mp.p.ptr() == pp && w.mp.curg != nil && readgstatus(w.mp.curg)&^_Gscan == _Gsyscall { status = traceProcSyscall } case _Psyscall: