Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong frame name in error.StackFrames(), right in debug.PrintStack() #38284

Closed
entonio opened this issue Apr 6, 2020 · 2 comments
Closed

Wrong frame name in error.StackFrames(), right in debug.PrintStack() #38284

entonio opened this issue Apr 6, 2020 · 2 comments

Comments

@entonio
Copy link

entonio commented Apr 6, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.7 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/_______/Library/Caches/go-build"
GOENV="/Users/_______/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/usr/local/Golang"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.7/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d4/6j16w88s5093ml10wxv7txf00000gn/T/go-build792912624=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  • I tried to recreate a stack trace in go that looks like what we have in java.
  • I got the frames using errors.Wrap(errors.New(""), 0).StackFrames()
  • I noticed that on some frames Name is wrong, repeating the N+1 frame or worse
  • The function itself appears to be wrong, getting its name does the same
  • Sometimes even extra frames appear, this example has one
  • When using debug.Stack(), the Name is right
  • Go playgound: https://play.golang.org/p/qQS6klSf1Iu
  • Lest you believe the problem is with my code, I've included the output of errors.Wrap(errors.New(""), 0).StackFrames().

What did you expect to see?

  • The correct function name

What did you see instead?

  • The name of the function in one of the other frames
  • Sometimes even extra frames appear, this example has one

Could this be related to #34123?

@ianlancetaylor
Copy link
Contributor

If the name is correct in debug.PrintStack but incorrect in errors.StackFrames, then it seems to me that this is a bug in errors.StackFrames. In that case this bug should be reported against that package, not here.

From a very very quick glance at errors.StackFrames, it looks like it is not using runtime.CallersFrames. That may be the problem.

In any case I'm going to close this issue, since I don't think it's a problem with the Go project.

@entonio
Copy link
Author

entonio commented Apr 7, 2020

I completely missed the fact that this is an external package, sorry.

@golang golang locked and limited conversation to collaborators Apr 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants