From: Michael Anthony Knyszek Date: Tue, 28 Jul 2020 20:02:57 +0000 (+0000) Subject: runtime: hold sched.lock over globrunqputbatch in runqputbatch X-Git-Tag: go1.15rc2~1^2~12 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6b4dcf19fa;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Michael Pratt Reviewed-by: Cherry Zhang Reviewed-by: Ian Lance Taylor --- diff --git a/src/runtime/proc.go b/src/runtime/proc.go index ed1aa1c194..035822216d 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -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) } }