1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:20:06 -07:00

cmd/compile: mark instantiated functions from package runtime as norace

Fixes #60439

Change-Id: I09fcd2d3deb7f80ed012a769fdb6f53b09c0290b
Reviewed-on: https://go-review.googlesource.com/c/go/+/502895
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2023-06-13 22:25:50 +07:00 committed by Gopher Robot
parent 8c5a54f698
commit 5b2ddfadb2
3 changed files with 22 additions and 0 deletions

View File

@ -118,6 +118,16 @@ func unified(m posMap, noders []*noder) {
}
}
// For functions originally came from package runtime,
// mark as norace to prevent instrumenting, see issue #60439.
for _, n := range target.Decls {
if fn, ok := n.(*ir.Func); ok {
if !base.Flag.CompilingRuntime && types.IsRuntimePkg(fn.Sym().Pkg) {
fn.Pragma |= ir.Norace
}
}
}
base.ExitIfErrors() // just in case
}

View File

@ -1932,3 +1932,11 @@ func SetPinnerLeakPanic(f func()) {
func GetPinnerLeakPanic() func() {
return pinnerLeakPanic
}
var testUintptr uintptr
func MyGenericFunc[T any]() {
systemstack(func() {
testUintptr = 4
})
}

View File

@ -929,3 +929,7 @@ func TestMemoryLimitNoGCPercent(t *testing.T) {
t.Fatalf("expected %q, but got %q", want, got)
}
}
func TestMyGenericFunc(t *testing.T) {
runtime.MyGenericFunc[int]()
}