diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go index c0326c547b4..9b865bbee93 100644 --- a/src/cmd/compile/internal/gc/dcl.go +++ b/src/cmd/compile/internal/gc/dcl.go @@ -1575,6 +1575,9 @@ func (c *nowritebarrierrecChecker) visitcall(n *Node) { if fn == nil || fn.Op != ONAME || fn.Class != PFUNC || fn.Name.Defn == nil { return } + if (compiling_runtime != 0 || fn.Sym.Pkg == Runtimepkg) && fn.Sym.Name == "allocm" { + return + } defn := fn.Name.Defn fnbest, ok := c.best[defn] diff --git a/src/runtime/proc.go b/src/runtime/proc.go index f47c4bef5b2..f89669f2a16 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -1182,6 +1182,9 @@ type cgothreadstart struct { // Allocate a new m unassociated with any thread. // Can use p for allocation context if needed. // fn is recorded as the new m's m.mstartfn. +// +// This function it known to the compiler to inhibit the +// go:nowritebarrierrec annotation because it uses P for allocation. func allocm(_p_ *p, fn func()) *m { _g_ := getg() _g_.m.locks++ // disable GC because it can be called from sysmon