aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-04-25 22:39:56 -0700
committerIan Lance Taylor <iant@golang.org>2019-04-29 22:35:35 +0000
commit98c5a56f0178db479c71fa76b5791ce2fcfc58b9 (patch)
tree328524cdc87ce8696432f7a10ad0570f6e86dfd0 /src/runtime/proc.go
parentccbc9a3f9f6479070f5a45a8583d14d158b8bcb0 (diff)
downloadgo-98c5a56f0178db479c71fa76b5791ce2fcfc58b9.tar.xz
runtime: account for callbacks in checkdead on Windows
When a callback runs on a different thread in Windows, as in the runtime package test TestCallbackInAnotherThread, it will use the extra M. That can cause the test in checkdead to fail incorrectly. Check whether there actually is an extra M before expecting it. I think this is a general problem unrelated to timers. I think the test was passing previously because the timer goroutine was using an M. But I haven't proved that. This change seems correct, and it avoids the test failure when using the new timers on Windows. Updates #27707 Change-Id: Ieb31c04ff0354d6fae7e173b59bcfadb8b0464cd Reviewed-on: https://go-review.googlesource.com/c/go/+/174037 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 1871d3b248..b8ee616eaa 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -4187,7 +4187,12 @@ func checkdead() {
// for details.)
var run0 int32
if !iscgo && cgoHasExtraM {
- run0 = 1
+ mp := lockextra(true)
+ haveExtraM := extraMCount > 0
+ unlockextra(mp)
+ if haveExtraM {
+ run0 = 1
+ }
}
run := mcount() - sched.nmidle - sched.nmidlelocked - sched.nmsys