File tree 1 file changed +8
-0
lines changed 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1293,6 +1293,8 @@ func mstart1() {
1293
1293
//go:yeswritebarrierrec
1294
1294
func mstartm0 () {
1295
1295
// 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.
1296
1298
if (iscgo || GOOS == "windows" ) && ! cgoHasExtraM {
1297
1299
cgoHasExtraM = true
1298
1300
newextram ()
@@ -1620,6 +1622,9 @@ func allocm(_p_ *p, fn func()) *m {
1620
1622
func needm (x byte ) {
1621
1623
if (iscgo || GOOS == "windows" ) && ! cgoHasExtraM {
1622
1624
// 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
+ //
1623
1628
// Can not throw, because scheduler is not initialized yet.
1624
1629
write (2 , unsafe .Pointer (& earlycgocallback [0 ]), int32 (len (earlycgocallback )))
1625
1630
exit (1 )
@@ -4215,6 +4220,9 @@ func checkdead() {
4215
4220
return
4216
4221
}
4217
4222
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.)
4218
4226
var run0 int32
4219
4227
if ! iscgo && cgoHasExtraM {
4220
4228
run0 = 1
You can’t perform that action at this time.
0 commit comments