-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: Panic induced by nil pointer in struct initializer always points at the last line #8987
Comments
To implement this we would need accurate file/line information for each pointer dereference that might be nil. I expect that would increase the size of binaries, and the payback would be very small. I'm not sure it's worth it. Labels changed: added repo-main, release-none. Status changed to Thinking. |
Either line would be fine (as either would unambiguously point to the problem being with dereferencing p). In this particular case, the compiler falsely reports the error as being with line 13, when instead it means "somewhere in line 11-13". In my non-reduced error case it meant I had to go through 15 statements and try to figure out which one was actually causing the exception. The fact that I first had to figure out that when the error said "nil panic on line 270" it actually meant "nil panic on line 267" did not help in debugging. |
@SRabbelier FYI running on Go1.8 on the playground https://play.golang.org/p/R1h4hdN05S runtime.Version: go1.8
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0xffffffff addr=0x0 pc=0xc8a24]
goroutine 1 [running]:
main.main()
/tmp/sandbox483844785/main.go:15 +0xe4 and I've highlighted the expected line 15 where the panic occured, unless I misinterpreted what's going on. @ianlancetaylor should we close this issue? *
tp https://play.golang.org/p/uYkaVNd6LN |
That's great, thanks! I consider this fixed. |
Thanks also, @odeke-em, for tracking this one down as well. Not sure when/why this is fixed now, but I see the same result all the way back to 1.5. For what it's worth, at tip (with position information no set to the left-most token uniquely identifying a syntactic construct) the error line is the line where the Closing this as well. If there are cases we've missed we can file new issues... |
by SRabbelier:
The text was updated successfully, but these errors were encountered: