]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: mark instantiated functions from package runtime as norace
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 13 Jun 2023 15:25:50 +0000 (22:25 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 9 Aug 2023 17:03:21 +0000 (17:03 +0000)
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>
src/cmd/compile/internal/noder/unified.go
src/runtime/export_test.go
src/runtime/gc_test.go

index 6c4ac66e3d0eac1be69ebeebd0ea0e458d2416a7..0afa505550c8172ef6d9e6fa0d73e5ddc54a25aa 100644 (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
 }
 
index 5641005401aa41e8fa7cd547b2905446d40f1920..a4a1fa580d1221be085e488bf5c922a76aba2390 100644 (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
+       })
+}
index bd01e3610300dbc1d076691aaa453f9bf4e08709..0c21cd43cd9faccc180840cf1bdc1875e1b7f8b7 100644 (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]()
+}