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
runtime: Stack behaves differently between go1.8 and go1.9 #22916
Labels
Comments
This is working as intended. In go 1.9 stack traces are no longer affected in the presence of inlining. Put another way, go1.9 is correct, go 1.8 and earlier are wrong.
Ref. https://golang.org/doc/go1.9#callersframes
… On 29 Nov 2017, at 17:21, Yuan Yizhe ***@***.***> wrote:
What version of Go are you using (go version)?
go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/2yz/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/22/0c8jxg0j0j54f7xcw9zd0m8m0000gn/T/go-build362850491=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
package main
import (
"runtime/debug"
)
func main() {
PrintStack().nothing()
}
func PrintStack() Nothing {
debug.PrintStack()
return Nothing{}
}
type Nothing struct{}
func (Nothing) nothing() {}
https://play.golang.org/p/0DaVrfpCST
What did you expect to see?
go1.8.3 result
goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x109c981)
/usr/local/Cellar/go/1.8.3/libexec/src/runtime/debug/stack.go:24 +0x79
runtime/debug.PrintStack()
/usr/local/Cellar/go/1.8.3/libexec/src/runtime/debug/stack.go:16 +0x22
main.PrintStack()
/Users/2yz/go/src/github.com/2yz/stack/main.go:12 +0x20
main.main()
/Users/2yz/go/src/github.com/2yz/stack/main.go:8 +0x20
What did you see instead?
go1.9.2 result
goroutine 1 [running]:
runtime/debug.Stack(0x1004034, 0xc42001e0b8, 0x0)
/usr/local/Cellar/go/1.9.2/libexec/src/runtime/debug/stack.go:24 +0xa7
runtime/debug.PrintStack()
/usr/local/Cellar/go/1.9.2/libexec/src/runtime/debug/stack.go:16 +0x22
main.PrintStack()
/Users/2yz/go/src/github.com/2yz/stack/main.go:12 +0x20
main.Nothing.nothing(...)
/Users/2yz/go/src/github.com/2yz/stack/main.go:8
main.main()
/Users/2yz/go/src/github.com/2yz/stack/main.go:8 +0x20
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Thanks, @davecheney |
Thanks |
@davecheney That doesn't make sense. Changing this line
to the equivalent
yields the expected result.
|
Can you try Go master (what will become Go 1.10) ? |
Actually, I just did. And it's fixed with Go 1.10:
This isn't critical enough to warrant a backport to Go 1.9, though. (I assume.) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/0DaVrfpCST
What did you expect to see?
go1.8.3 result
What did you see instead?
go1.9.2 result
main.Nothing.nothing()
is included in the call stack in go1.9.2The text was updated successfully, but these errors were encountered: