aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-07 12:27:24 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-07 12:27:36 -0700
commit0e39cdc0e9d76ba06d8cf3096ab94f17b1ffefb3 (patch)
tree11c736d419de5f33c484cb025b3c9cddbdcdb918 /src/runtime/proc.go
parent7c8a5be2d6f26caed84c6bae2a115872af5b1021 (diff)
parent821270787109408ae7c86a01ccc93162be9c020c (diff)
downloadgo-0e39cdc0e9d76ba06d8cf3096ab94f17b1ffefb3.tar.gz
go-0e39cdc0e9d76ba06d8cf3096ab94f17b1ffefb3.zip
[dev.typeparams] all: merge master (8212707) into dev.typeparams
Conflicts: - src/go/internal/gcimporter/iimport.go CL 325429 and CL 319931 made unrelated changes to adjacent lines Merge List: + 2021-06-07 8212707871 crypto/elliptic: update P-521 docs to say it's constant-time + 2021-06-07 7406180012 fmt: split package documentation into more sections + 2021-06-07 e3176bbc3e crypto/tls: fix typo in Config.NextProtos docs + 2021-06-05 e1fa26026d spec: improve wording consistency by eliminating "specifier" + 2021-06-05 f490134126 spec: improve wording by choosing an official term "keyword" + 2021-06-05 e3cb381704 go/internal/gcimporter: don't waste CPU copying bytes in `io.ReadAll` + 2021-06-05 9d669ed47a misc/cgo/errors: use expected column numbers + 2021-06-04 95939e8de7 cmd/compile/internal/abi: fix typo in comment + 2021-06-04 831f9376d8 net/http: fix ResponseWriter.ReadFrom with short reads + 2021-06-04 3a9d906edc os: avoid finalizer race in windows process object + 2021-06-04 105c5b50e0 os: terminate windows processes via handle directly + 2021-06-04 79cd407f88 syscall: regenerate zsyscall_windows.go + 2021-06-04 c6b6211229 doc/go1.17: document testing changes for Go 1.17 + 2021-06-04 0214440075 syscall: do not pass console handles to PROC_THREAD_ATTRIBUTE_HANDLE_LIST on Windows 7 + 2021-06-04 962d5c997a cmd/compile,go/types: restrict use of unsafe.{Add,Slice} to go1.17 or newer + 2021-06-04 b29b123e07 cmd/compile: remove spurious ir.Dump + 2021-06-03 6d98301114 cmd/link: use correct alignment in PE DWARF sections + 2021-06-03 e0d029f758 runtime: avoid gp.lockedm race in exitsyscall0 + 2021-06-02 dd7ba3ba2c net: don't rely on system hosts in TestCVE202133195 + 2021-06-02 4f572d7076 io/fs: minor corrections to Sub docs + 2021-06-02 e11d14225c doc/go1.17: remove runtime section + 2021-06-02 6e189afd3e doc/go1.17: mention SYS_WAIT6/WEXITED on NetBSD + 2021-06-02 ff9f5fb859 cmd/link: recognize clang linker error in testCGOLTO + 2021-06-02 1c6a2ea2ea doc/go1.17: document time changes for Go1.17 + 2021-06-02 d743e67e06 doc/go1.17: document flag changes for Go 1.17 + 2021-06-02 dc8f87b749 runtime/internal/sys: generate //go:build lines in gengoos.go + 2021-06-02 84c0e5d47f cmd/link: move issue 43830 tests out of TestScript + 2021-06-02 cae68700cc runtime: fix formatting + 2021-06-01 567ee865f6 cmd/go: add declaration to cgo_lto_issue43830 test + 2021-06-01 24e9707cbf cmd/link, cmd/cgo: support -flto in CFLAGS Change-Id: I9ef88e7de0f8b1841ed9604b613b41672df67e71
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 63eeb6c9c7..24566e5efa 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -4071,8 +4071,16 @@ func exitsyscall0(gp *g) {
if schedEnabled(gp) {
_p_ = pidleget()
}
+ var locked bool
if _p_ == nil {
globrunqput(gp)
+
+ // Below, we stoplockedm if gp is locked. globrunqput releases
+ // ownership of gp, so we must check if gp is locked prior to
+ // committing the release by unlocking sched.lock, otherwise we
+ // could race with another M transitioning gp from unlocked to
+ // locked.
+ locked = gp.lockedm != 0
} else if atomic.Load(&sched.sysmonwait) != 0 {
atomic.Store(&sched.sysmonwait, 0)
notewakeup(&sched.sysmonnote)
@@ -4082,7 +4090,7 @@ func exitsyscall0(gp *g) {
acquirep(_p_)
execute(gp, false) // Never returns.
}
- if gp.lockedm != 0 {
+ if locked {
// Wait until another thread schedules gp and so m again.
//
// N.B. lockedm must be this M, as this g was running on this M