Skip to content

Commit

Permalink
runtime: handle windows callback on non-go thread
Browse files Browse the repository at this point in the history
  • Loading branch information
billziss-gh committed May 26, 2018
1 parent dbafdac commit 36a8ac8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/runtime/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ func mstart1() {
//go:yeswritebarrierrec
func mstartm0() {
// Create an extra M for callbacks on threads not created by Go.
if iscgo && !cgoHasExtraM {
if (iscgo || GOOS == "windows") && !cgoHasExtraM {
cgoHasExtraM = true
newextram()
}
Expand Down Expand Up @@ -1618,7 +1618,7 @@ func allocm(_p_ *p, fn func()) *m {
// put the m back on the list.
//go:nosplit
func needm(x byte) {
if iscgo && !cgoHasExtraM {
if (iscgo || GOOS == "windows") && !cgoHasExtraM {
// Can happen if C/C++ code calls Go from a global ctor.
// Can not throw, because scheduler is not initialized yet.
write(2, unsafe.Pointer(&earlycgocallback[0]), int32(len(earlycgocallback)))
Expand Down Expand Up @@ -4215,8 +4215,13 @@ func checkdead() {
return
}

var run0 int32
if !iscgo && cgoHasExtraM {
run0 = 1
}

run := mcount() - sched.nmidle - sched.nmidlelocked - sched.nmsys
if run > 0 {
if run > run0 {
return
}
if run < 0 {
Expand Down
2 changes: 0 additions & 2 deletions src/runtime/syscall_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ func TestBlockingCallback(t *testing.T) {
}

func TestCallbackInAnotherThread(t *testing.T) {
t.Skip("Skipping failing test (see golang.org/issue/6751 for details)")

d := GetDLL(t, "kernel32.dll")

f := func(p uintptr) uintptr {
Expand Down

0 comments on commit 36a8ac8

Please sign in to comment.