From: Michael Anthony Knyszek Date: Tue, 10 May 2022 15:09:12 +0000 (+0000) Subject: runtime: profile finalizer G more carefully in goroutine profile X-Git-Tag: go1.19beta1~334 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8fdd277fe6ee1770b12650a4bc2bc257e49c8065;p=gostls13.git runtime: profile finalizer G more carefully in goroutine profile If SetFinalizer is never called, we might readgstatus on a nil fing variable, resulting in a crash. This change guards code that accesses fing by a nil check. Fixes #52821. Change-Id: I3e8e7004f97f073dc622e801a1d37003ea153a29 Reviewed-on: https://go-review.googlesource.com/c/go/+/405475 Run-TryBot: Michael Knyszek Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Rhys Hiltner --- diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index cd63bafebb..2046e9f245 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -952,9 +952,9 @@ func goroutineProfileWithLabelsConcurrent(p []StackRecord, labels []unsafe.Point // system goroutine (to be excluded). Pick one before restarting the world. if fing != nil { fing.goroutineProfiled.Store(goroutineProfileSatisfied) - } - if readgstatus(fing) != _Gdead && !isSystemGoroutine(fing, false) { - doRecordGoroutineProfile(fing) + if readgstatus(fing) != _Gdead && !isSystemGoroutine(fing, false) { + doRecordGoroutineProfile(fing) + } } startTheWorld()