]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: avoid gp.lockedm race in exitsyscall0
authorMichael Pratt <mpratt@google.com>
Wed, 2 Jun 2021 21:44:43 +0000 (17:44 -0400)
committerMichael Pratt <mpratt@google.com>
Thu, 3 Jun 2021 16:34:34 +0000 (16:34 +0000)
commite0d029f75846f84f79e63f6100c57047f4a3fa98
tree6b484095dea6e9aa1ae8cff0c0efe8532cc53883
parentdd7ba3ba2c860c40be6d70b63d4a678449cae80f
runtime: avoid gp.lockedm race in exitsyscall0

Following https://golang.org/cl/291329, exitsyscall0 accesses gp.lockedm
after releasing gp to the global runq. This creates a race window where
another M may schedule the (unlocked) G, which subsequently calls
LockOSThread, setting gp.lockedm and thus causing exitsyscall0 to think
it should call stoplockedm.

Avoid this race by checking if gp is locked before releasing it to the
global runq.

Fixes #46524

Change-Id: I3acdaf09e7a2178725adbe61e985130e9ebd0680
Reviewed-on: https://go-review.googlesource.com/c/go/+/324350
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/proc.go