]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: hold sched.lock over globrunqputbatch in runqputbatch
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 28 Jul 2020 20:02:57 +0000 (20:02 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 30 Jul 2020 15:46:39 +0000 (15:46 +0000)
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>
src/runtime/proc.go

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