File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1293,6 +1293,8 @@ func mstart1() {
12931293//go:yeswritebarrierrec
12941294func mstartm0 () {
12951295 // Create an extra M for callbacks on threads not created by Go.
1296+ // An extra M is also needed on Windows for callbacks created by
1297+ // syscall.NewCallback.
12961298 if (iscgo || GOOS == "windows" ) && ! cgoHasExtraM {
12971299 cgoHasExtraM = true
12981300 newextram ()
@@ -1620,6 +1622,9 @@ func allocm(_p_ *p, fn func()) *m {
16201622func needm (x byte ) {
16211623 if (iscgo || GOOS == "windows" ) && ! cgoHasExtraM {
16221624 // Can happen if C/C++ code calls Go from a global ctor.
1625+ // Can also happen on Windows if a global ctor uses a
1626+ // callback created using syscall.NewCallback.
1627+ //
16231628 // Can not throw, because scheduler is not initialized yet.
16241629 write (2 , unsafe .Pointer (& earlycgocallback [0 ]), int32 (len (earlycgocallback )))
16251630 exit (1 )
@@ -4215,6 +4220,9 @@ func checkdead() {
42154220 return
42164221 }
42174222
4223+ // If we are not running under cgo, but we have an extra M then account
4224+ // for it. (It is possible to have an extra M on Windows without cgo to
4225+ // accommodate callbacks created by syscall.NewCallback.)
42184226 var run0 int32
42194227 if ! iscgo && cgoHasExtraM {
42204228 run0 = 1
You can’t perform that action at this time.
0 commit comments