1
0
mirror of https://github.com/golang/go synced 2024-11-15 04:20:22 -07:00

runtime: hold sched.lock over globrunqputbatch in runqputbatch

globrunqputbatch should never be called without sched.lock held.
runqputbatch's documentation even says it may acquire sched.lock in
order to call it.

Fixes #40457.

Change-Id: I5421b64f1da3a6087dfebbef7203db0c95d213a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/245377
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Michael Anthony Knyszek 2020-07-28 20:02:57 +00:00 committed by Michael Knyszek
parent 85afa2eb19
commit 6b4dcf19fa

View File

@ -5225,7 +5225,9 @@ func runqputbatch(pp *p, q *gQueue, qsize int) {
atomic.StoreRel(&pp.runqtail, t) atomic.StoreRel(&pp.runqtail, t)
if !q.empty() { if !q.empty() {
lock(&sched.lock)
globrunqputbatch(q, int32(qsize)) globrunqputbatch(q, int32(qsize))
unlock(&sched.lock)
} }
} }