diff --git a/src/runtime/os1_windows.go b/src/runtime/os1_windows.go index 561d3ce4575..4ae1a8411b6 100644 --- a/src/runtime/os1_windows.go +++ b/src/runtime/os1_windows.go @@ -359,6 +359,8 @@ func nanotime() int64 { } // Calling stdcall on os stack. +// May run during STW, so write barriers are not allowed. +//go:nowritebarrier //go:nosplit func stdcall(fn stdFunction) uintptr { gp := getg() @@ -367,7 +369,8 @@ func stdcall(fn stdFunction) uintptr { if mp.profilehz != 0 { // leave pc/sp for cpu profiler - mp.libcallg = gp + // gp is on allg, so this WB can be eliminated. + setGNoWriteBarrier(&mp.libcallg, gp) mp.libcallpc = getcallerpc(unsafe.Pointer(&fn)) // sp must be the last, because once async cpu profiler finds // all three values to be non-zero, it will use them