]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] runtime: fix misuse of funcPC
authorCherry Mui <cherryyz@google.com>
Fri, 21 May 2021 01:40:32 +0000 (21:40 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 21 May 2021 22:12:18 +0000 (22:12 +0000)
funcPC expects a func value. There are places where we pass an
unsafe.Pointer, which is technically undefined.

In proc.go it is actually representing a func value, so the
expression does the right thing. Cast to a func value so it is
clearer.

In os_freebsd.go it is a raw function pointer. Using funcPC on a
raw function pointer is incorrect. Just use it directly instead.

Change-Id: I3c5d61cea08f0abf5737834b520f9f1b583c1d34
Reviewed-on: https://go-review.googlesource.com/c/go/+/321953
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/os_freebsd.go
src/runtime/proc.go

index 41feaecf6b659357183cd47caa0affcfc60deafb..151a5fd91abe5c8fbc82fcec6f44d55cf1abdfd1 100644 (file)
@@ -237,7 +237,7 @@ func newosproc0(stacksize uintptr, fn unsafe.Pointer) {
        // However, newosproc0 is currently unreachable because builds
        // utilizing c-shared/c-archive force external linking.
        param := thrparam{
-               start_func: funcPC(fn),
+               start_func: uintptr(fn),
                arg:        nil,
                stack_base: uintptr(stack), //+stacksize?
                stack_size: stacksize,
index 694f456ac5e2fdca893ca2625fd4364b7d0ce7ab..6c896cb993ecd0c3c69ddd6a5ede2c858457142b 100644 (file)
@@ -6487,7 +6487,8 @@ func doInit(t *initTask) {
                        // Load stats non-atomically since tracinit is updated only by this init goroutine.
                        after := inittrace
 
-                       pkg := funcpkgpath(findfunc(funcPC(firstFunc)))
+                       f := *(*func())(unsafe.Pointer(&firstFunc))
+                       pkg := funcpkgpath(findfunc(funcPC(f)))
 
                        var sbuf [24]byte
                        print("init ", pkg, " @")