From 1ab063ce532f72851cef735238ba656cc7680b66 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 17 May 2019 13:31:12 -0700 Subject: [PATCH] testing: callerName only needs one PC in the traceback callerName requested 2 PCs from Callers, and that causes both to be looked up in the file/line mapping. We really only need to do the work for one PC. (And in fact the caller doesn't need file/line at all, but the Callers API can't express that.) We used to request 2 PCs because in 1.11 and earlier we stored an inline skip count in the second entry. That's not necessary any more (as of 1.12). Fixes #32093 Change-Id: I7b272626ef6496e848ee8af388cdaafd2556857b Reviewed-on: https://go-review.googlesource.com/c/go/+/177858 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor Reviewed-by: Caleb Spare --- src/testing/testing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testing/testing.go b/src/testing/testing.go index 753de9f27c..339df13f43 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -771,7 +771,7 @@ func (c *common) Helper() { // for the caller after skip frames (where 0 means the current function). func callerName(skip int) string { // Make room for the skip PC. - var pc [2]uintptr + var pc [1]uintptr n := runtime.Callers(skip+2, pc[:]) // skip + runtime.Callers + callerName if n == 0 { panic("testing: zero callers found")