]> Cypherpunks repositories - gostls13.git/commit
runtime: prevent preemption while releasing worldsema in gcStart
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 15 Apr 2020 18:01:00 +0000 (18:01 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 16 Apr 2020 02:35:01 +0000 (02:35 +0000)
commit03ba6b070d625bf00eac5350c4f363e5e87828b2
tree55f0d7ba160e89a9ea4c36d88da13611fb2460fb
parentc4961dc247ca39c251a5a3c80ebfe59609b4e669
runtime: prevent preemption while releasing worldsema in gcStart

Currently, as a result of us releasing worldsema now to allow STW events
during a mark phase, we release worldsema between starting the world and
having the goroutine block in STW mode. This inserts preemption points
which, if followed through, could lead to a deadlock. Specifically,
because user goroutine scheduling is disabled in STW mode, the goroutine
will block before properly releasing worldsema.

The fix here is to prevent preemption while releasing the worldsema.

Fixes #38404.
Updates #19812.

Change-Id: I8ed5b3aa108ab2e4680c38e77b0584fb75690e3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/228337
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mgc.go