aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgc.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2020-10-28 18:06:05 -0400
committerMichael Pratt <mpratt@google.com>2020-10-30 20:20:58 +0000
commit6abbfc17c255c07134a69c3ca305231db80530ec (patch)
tree0c63ed03f28c20d9927ee8c4352ba0d16f76cb99 /src/runtime/mgc.go
parent94b3fd06cb431358f45786246cd279c8bdb9370b (diff)
downloadgo-6abbfc17c255c07134a69c3ca305231db80530ec.tar.gz
go-6abbfc17c255c07134a69c3ca305231db80530ec.zip
runtime: add world-stopped assertions
Stopping the world is an implicit lock for many operations, so we should assert the world is stopped in functions that require it. This is enabled along with the rest of lock ranking, though it is a bit orthogonal and likely cheap enough to enable all the time should we choose. Requiring a lock _or_ world stop is common, so that can be expressed as well. Updates #40677 Change-Id: If0a58544f4251d367f73c4120c9d39974c6cd091 Reviewed-on: https://go-review.googlesource.com/c/go/+/248577 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Trust: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mgc.go')
-rw-r--r--src/runtime/mgc.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index 9d2682f03c..fb3c149942 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -2164,6 +2164,8 @@ func gcMark(start_time int64) {
//
//go:systemstack
func gcSweep(mode gcMode) {
+ assertWorldStopped()
+
if gcphase != _GCoff {
throw("gcSweep being done but phase is not GCoff")
}