Skip to content

Commit 36a8ac8

Browse files
committed
runtime: handle windows callback on non-go thread
1 parent dbafdac commit 36a8ac8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/runtime/proc.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ func mstart1() {
12931293
//go:yeswritebarrierrec
12941294
func mstartm0() {
12951295
// Create an extra M for callbacks on threads not created by Go.
1296-
if iscgo && !cgoHasExtraM {
1296+
if (iscgo || GOOS == "windows") && !cgoHasExtraM {
12971297
cgoHasExtraM = true
12981298
newextram()
12991299
}
@@ -1618,7 +1618,7 @@ func allocm(_p_ *p, fn func()) *m {
16181618
// put the m back on the list.
16191619
//go:nosplit
16201620
func needm(x byte) {
1621-
if iscgo && !cgoHasExtraM {
1621+
if (iscgo || GOOS == "windows") && !cgoHasExtraM {
16221622
// Can happen if C/C++ code calls Go from a global ctor.
16231623
// Can not throw, because scheduler is not initialized yet.
16241624
write(2, unsafe.Pointer(&earlycgocallback[0]), int32(len(earlycgocallback)))
@@ -4215,8 +4215,13 @@ func checkdead() {
42154215
return
42164216
}
42174217

4218+
var run0 int32
4219+
if !iscgo && cgoHasExtraM {
4220+
run0 = 1
4221+
}
4222+
42184223
run := mcount() - sched.nmidle - sched.nmidlelocked - sched.nmsys
4219-
if run > 0 {
4224+
if run > run0 {
42204225
return
42214226
}
42224227
if run < 0 {

src/runtime/syscall_windows_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ func TestBlockingCallback(t *testing.T) {
251251
}
252252

253253
func TestCallbackInAnotherThread(t *testing.T) {
254-
t.Skip("Skipping failing test (see golang.org/issue/6751 for details)")
255-
256254
d := GetDLL(t, "kernel32.dll")
257255

258256
f := func(p uintptr) uintptr {

0 commit comments

Comments
 (0)