]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.24] runtime: cleanup M vgetrandom state before dropping P
authorMichael Pratt <mpratt@google.com>
Thu, 3 Apr 2025 03:26:25 +0000 (03:26 +0000)
committerCarlos Amedee <carlos@golang.org>
Mon, 28 Apr 2025 17:33:46 +0000 (10:33 -0700)
commit0ab64e2caad9c09f6db3de23898a2294b07b9fd3
tree14a53a2be0928fe38cd03b1ad2b83183ff374ca5
parent56eb99859d054fde8ec2927ebf665667382ddbc6
[release-branch.go1.24] runtime: cleanup M vgetrandom state before dropping P

When an M is destroyed, we put its vgetrandom state back on the shared
list for another M to reuse. This list is simply a slice, so appending
to the slice may allocate. Currently this operation is performed in
mdestroy, after the P is released, meaning allocation is not allowed.

More the cleanup earlier in mdestroy when allocation is still OK.

Also add //go:nowritebarrierrec to mdestroy since it runs without a P,
which would have caught this bug.

Fixes #73144.
For #73141.

Change-Id: I6a6a636c3fbf5c6eec09d07a260e39dbb4d2db12
Reviewed-on: https://go-review.googlesource.com/c/go/+/662455
Reviewed-by: Jason Donenfeld <Jason@zx2c4.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 0b31e6d4cc804ab76ae8ced151ee2f50657aec14)
Reviewed-on: https://go-review.googlesource.com/c/go/+/662496
12 files changed:
src/runtime/os3_solaris.go
src/runtime/os_aix.go
src/runtime/os_darwin.go
src/runtime/os_dragonfly.go
src/runtime/os_linux.go
src/runtime/os_netbsd.go
src/runtime/os_openbsd.go
src/runtime/os_plan9.go
src/runtime/os_windows.go
src/runtime/proc.go
src/runtime/vgetrandom_linux.go
src/runtime/vgetrandom_unsupported.go