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

runtime: panic reported on wrong line on deferred statements #41180

Closed
fracasula opened this issue Sep 2, 2020 · 3 comments
Closed

runtime: panic reported on wrong line on deferred statements #41180

fracasula opened this issue Sep 2, 2020 · 3 comments
Milestone

Comments

@fracasula
Copy link

@fracasula fracasula commented Sep 2, 2020

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

$ go version
go version go1.15.1 linux/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="/home/francesco/.cache/go-build"
GOENV="/home/francesco/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/francesco/go/pkg/mod"
GONOPROXY="github.com/netdata/*"
GONOSUMDB="github.com/netdata/*"
GOOS="linux"
GOPATH="/home/francesco/go"
GOPRIVATE="github.com/netdata/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2 -Wno-incompatible-pointer-types"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build091588623=/tmp/go-build -gno-record-gcc-switches"

What did you do?

If we try to close a nil channel on a defer, or if we try to call a nil function on a defer, then we get a panic on the return statement while the line with the defer is not reported in the stack trace.

https://play.golang.org/p/mcO-A4WRWXC

https://play.golang.org/p/eQnYvAcaLCD

What did you expect to see?

I'd expect to see the defer statement in the panic stack trace. If you look at the links to the playground above, line 10 is not reported, we can see only lines 12 and 16.

What did you see instead?

I see only lines 12 and 16, not line 10 (the one with the defer).

@dmitshur dmitshur changed the title Panic reported on wrong line on deferred statements runtime: panic reported on wrong line on deferred statements Sep 2, 2020
@dmitshur
Copy link
Member

@dmitshur dmitshur commented Sep 2, 2020

Thanks for reporting. Do you know if this happens with older releases too?

/cc @aclements @randall77 @mknyszek @prattmic per owners.

@dmitshur dmitshur added this to the Backlog milestone Sep 2, 2020
@fracasula
Copy link
Author

@fracasula fracasula commented Sep 2, 2020

@dmitshur I was running on 1.14.3 when I noticed and upgraded to 1.15.1 later just to check if this had been fixed by a newer release. So 1.14.3 is definitely affected. I checked now with 1.13.5 and it is affected as well.

@randall77
Copy link
Contributor

@randall77 randall77 commented Sep 2, 2020

This is intentional. We report the line number of the return point, because that's where the defer is executed (not where it is queued up). Discussion of maybe changing the behavior is at #29797. Closing as a dup.

@randall77 randall77 closed this Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.