-
Notifications
You must be signed in to change notification settings - Fork 18k
net: nil *Resolver not equivalent to zero resolver, despite doc #24330
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
Comments
There are actually a few places which will panic since access to PreferGo or StrictErrors does not check if the resolver is nil. |
Can't reproduce this exact example on
/cc @bradfitz |
Thank you for this catch @philpennock! In deed we made this promise but as @fraenkel noted, there are few places in which on UNIX like systems where we directly invoke fields on the *Resolver[1] On other systems we don't even seem to be touching *Resolver[1] Anyways this is just an oversight, we made that assertion ~1.5 years ago in September 2016, in this CL https://go-review.googlesource.com/29440 and commit 2bc5f12 but I'd suggest perhaps: [1]
|
Change https://golang.org/cl/101315 mentions this issue: |
What version of Go are you using (
go version
)?go version go1.10 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?
Tested the assertion at https://golang.org/pkg/net/#Resolver that:
https://play.golang.com/p/B40hcxy_Uuu
In the Go sandbox, it errors out because of the network restrictions. Run locally, this panics:
panic: runtime error: invalid memory address or nil pointer dereference
Swap the commenting-out of the
r
declaration to create a zero resolver, and the code runs perfectly.What did you expect to see?
No difference in output between the two ways of declaring the resolver, because the documentation explicitly asserts the behavior of a nil
*Resolver
.What did you see instead?
The text was updated successfully, but these errors were encountered: