From: Cherry Mui Date: Fri, 21 May 2021 01:40:32 +0000 (-0400) Subject: [dev.typeparams] runtime: fix misuse of funcPC X-Git-Tag: go1.18beta1~1818^2^2~506 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6a81e063dd;p=gostls13.git [dev.typeparams] runtime: fix misuse of funcPC 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 Reviewed-by: Michael Knyszek --- diff --git a/src/runtime/os_freebsd.go b/src/runtime/os_freebsd.go index 41feaecf6b..151a5fd91a 100644 --- a/src/runtime/os_freebsd.go +++ b/src/runtime/os_freebsd.go @@ -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, diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 694f456ac5..6c896cb993 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -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, " @")