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

net: race condition in dnsclient_unix.go resolverConfig init #15495

Closed
christievans opened this issue Apr 29, 2016 · 5 comments
Closed

net: race condition in dnsclient_unix.go resolverConfig init #15495

christievans opened this issue Apr 29, 2016 · 5 comments

Comments

@christievans
Copy link

@christievans christievans commented Apr 29, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
    GOARCH="arm"
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GO15VENDOREXPERIMENT="1"
    CC="gcc"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
    CXX="g++"
    CGO_ENABLED="1"
  3. What did you do?

We were seeing issues where systems in the field would get stuck reporting:

dial tcp: lookup mywebsite.com on [::1]:53: read udp [::1]:50878->[::1]:53: read: connection refused

even though /etc/resolv.conf was populated with a legitimate nameserver. Restarting the application fixed the issue.

We believe this happens when net/dnsclient_unix.go resolverConfig.init() happens to run at the same time as /etc/resolv.conf being updated from empty to populated. There's a chance for:

  1. Go reads empty /etc/resolv.conf, stores in conf.dnsConfig
  2. /etc/resolv.conf gets updated
  3. Go stat's /etc/resolv.conf, gets the new modTime and saves to conf.modTime
  4. Go thinks there are no nameservers, and based on modTime seemingly not changing, never refreshes conf.dnsConfig
@ianlancetaylor ianlancetaylor changed the title Race Condition in dnsclient_unix.go resolverConfig init net: race condition in dnsclient_unix.go resolverConfig init Apr 29, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.7Maybe milestone Apr 29, 2016
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 29, 2016

@mdempsky

This comment has been minimized.

Copy link
Member

@mdempsky mdempsky commented Apr 29, 2016

I think this is the same issue as #14072, which was fixed in golang.org/cl/18860. I'd be interested to know if you're able to reproduce the problem with Go at tip.

@mdempsky

This comment has been minimized.

Copy link
Member

@mdempsky mdempsky commented Apr 29, 2016

Alternatively, I think you should be able to backport that CL to 1.6 for testing.

@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented May 4, 2016

@christievans, can you confirm whether this is fixed for you at tip?

@christievans

This comment has been minimized.

Copy link
Author

@christievans christievans commented May 9, 2016

I pulled in the CL and that fixed it - thanks for the quick response!

@golang golang locked and limited conversation to collaborators May 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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