Skip to content

Commit 98c5a56

Browse files
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 <[email protected]>
1 parent ccbc9a3 commit 98c5a56

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/runtime/proc.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4187,7 +4187,12 @@ func checkdead() {
41874187
// for details.)
41884188
var run0 int32
41894189
if !iscgo && cgoHasExtraM {
4190-
run0 = 1
4190+
mp := lockextra(true)
4191+
haveExtraM := extraMCount > 0
4192+
unlockextra(mp)
4193+
if haveExtraM {
4194+
run0 = 1
4195+
}
41914196
}
41924197

41934198
run := mcount() - sched.nmidle - sched.nmidlelocked - sched.nmsys

0 commit comments

Comments
 (0)