net: LookupHost sometimes returns slice which when modified ruins cache state. #14212
Labels
Milestone
Comments
CL https://golang.org/cl/19201 mentions this issue. |
Is this a regression from Go 1.5? |
I observed it in Go 1.5.3 and it also exists at HEAD. |
In that case (since it's not a regression and lived with it in Go 1.5) we can fix it when the Go 1.7 dev tree opens up. /cc @mikioh |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
To reproduce:
Machine must have localhost specified in the /etc/hosts file.
Machine must NOT have localhost entry in its DNS Server.
Running this code:
Will output:
The first error message is able to resolve localhost but after modifying the returned addr slice, it no longer can.
I traced it down to the localStaticHost function returns a slice directly from the cache, rather than returning a copy of it.
I have a fix here: https://go-review.googlesource.com/#/c/19201/
The text was updated successfully, but these errors were encountered: