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

cmd/compile: nil pointer dereference for receivers has wrong line number #16462

Closed
dhowden opened this issue Jul 22, 2016 · 7 comments
Closed

Comments

@dhowden
Copy link
Contributor

dhowden commented Jul 22, 2016

Please answer these questions before submitting your issue. Thanks!

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

go version go1.6.3 darwin/amd64

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

GOARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

  1. What did you do?

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

Force nil-pointer dereference on receiver in method. The nil-dereference is reported as happening on the method call - line 25 - rather than on the actual deference which is inside the method (line 12).

  1. What did you expect to see?

0
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0xffffffff addr=0x0 pc=0x20146]

goroutine 1 [running]:
panic(0x13f4a0, 0x1040a038)
/usr/local/go/src/runtime/panic.go:481 +0x700
main.main()
/tmp/sandbox599323765/main.go:12 +0xe6

  1. What did you see instead?

0
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0xffffffff addr=0x0 pc=0x20146]

goroutine 1 [running]:
panic(0x13f4a0, 0x1040a038)
/usr/local/go/src/runtime/panic.go:481 +0x700
main.main()
/tmp/sandbox599323765/main.go:25 +0xe6

@josharian josharian changed the title Nil pointer dereference for receivers is incorrectly reported cmd/compile: nil pointer dereference for receivers has wrong line number Jul 22, 2016
@dominikh
Copy link
Member

This is a duplicate of #10152 and caused by inlining.

@davecheney
Copy link
Contributor

What happens if you disable inlining? -gcflags=-N

On Fri, 22 Jul 2016, 10:24 David Howden notifications@github.com wrote:

Please answer these questions before submitting your issue. Thanks!

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

go version go1.6.3 darwin/amd64

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

GOARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

  1. What did you do?

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

Force nil-pointer dereference on receiver in method. The nil-dereference
is reported as happening on the method call - line 25 - rather than on the
actual deference which is inside the method (line 12).

  1. What did you expect to see?

0
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0xffffffff addr=0x0 pc=0x20146]

goroutine 1 [running]:
panic(0x13f4a0, 0x1040a038)
/usr/local/go/src/runtime/panic.go:481 +0x700
main.main()
/tmp/sandbox599323765/main.go:12 +0xe6

  1. What did you see instead?

0
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0xffffffff addr=0x0 pc=0x20146]

goroutine 1 [running]:
panic(0x13f4a0, 0x1040a038)
/usr/local/go/src/runtime/panic.go:481 +0x700
main.main()
/tmp/sandbox599323765/main.go:25 +0xe6


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#16462, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAcA87Ce-2j-sSqT0qzYnldkSJqrOFlks5qYA3JgaJpZM4JSVwQ
.

@dhowden
Copy link
Contributor Author

dhowden commented Jul 22, 2016

@davecheney Still incorrect with inlining disabled.

$ go build -gcflags=-N example.go
$ ./example
0
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x231f]

goroutine 1 [running]:
panic(0xda980, 0xc82000a0f0)
    /usr/local/go/src/runtime/panic.go:481 +0x3e6
main.main()
    example.go:25 +0x26f

@dominikh
Copy link
Member

-N does not disable inlining, -l does.

@dhowden
Copy link
Contributor Author

dhowden commented Jul 22, 2016

Yeah, sorry. Just seen that too. With inlining disabled it shows the correct position.

$ go build -gcflags="-N -l" example.go
$ ./example
0
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x205d]

goroutine 1 [running]:
panic(0xda920, 0xc82000a0f0)
    /usr/local/go/src/runtime/panic.go:481 +0x3e6
main.(*Example).Value(0x0, 0x0)
    example.go:12 +0x1d
main.main()
    example.go:25 +0x12a

@davecheney
Copy link
Contributor

My mistake, I thought -N was a superset of -l. Show's how much I've used
that flag.

On Fri, Jul 22, 2016 at 2:41 PM, Dominik Honnef notifications@github.com
wrote:

-N does not disable inlining, -l does.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16462 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAcA3qTCn_f6XMCJELLMHRihEbrOV73ks5qYEoFgaJpZM4JSVwQ
.

@quentinmit
Copy link
Contributor

Closing as dupe of #10152, please comment if you think it's not.

@golang golang locked and limited conversation to collaborators Jul 29, 2017
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

5 participants