]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.23] runtime: handle system goroutines later in goroutine profiling
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 10 Jun 2025 16:42:59 +0000 (16:42 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 27 Jun 2025 17:06:42 +0000 (10:06 -0700)
commitdac4567503215483ce47f82fa8d15463f6da2d1f
tree71d50e166488ee232eecba5ed45789a0b7c676d3
parent3eedbde2376a9f394f748029061ab4f884d3f243
[release-branch.go1.23] runtime: handle system goroutines later in goroutine profiling

In Go 1.24 and earlier, it's possible for a just-starting finalizer
goroutine to have its stack traced in goroutine profiles even though
it shouldn't, because it wasn't visible to the goroutine profile STW.
This can also bump out other stacks, because the goroutine profiler
wasn't expecting to have another stack. Fix this by letting all
system goroutines participate in the goroutine profiler's state
machine, like in the CL this is cherry-picking. This ensures that the
finalizer goroutine will be counted as a system goroutine in this
just-starting state, but still composes with the old way of doing
things, because the finalizer goroutine is advanced to the terminal
state during the STW. In Go 1.25, this is fixing a slightly different
issue, but the root of the problem is the same: all goroutines should
participate in the profiler's state machine, and they do not.

For #74090.
Fixes #74362.

Change-Id: Icb9a164a033be22aaa942d19e828e895f700ca74
Reviewed-on: https://go-review.googlesource.com/c/go/+/680477
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 281cfcfc1b15fbb87fd32660b0a1d50be996d108)
Reviewed-on: https://go-review.googlesource.com/c/go/+/684097
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/runtime/mprof.go
src/runtime/pprof/pprof_test.go