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

Fix data race in dnsfilter #807

Closed
ameshkov opened this issue Jun 6, 2019 · 1 comment
Closed

Fix data race in dnsfilter #807

ameshkov opened this issue Jun 6, 2019 · 1 comment
Assignees
Milestone

Comments

@ameshkov
Copy link
Member

ameshkov commented Jun 6, 2019

The same issue with other global caches there.
We should not use global objects

==================
WARNING: DATA RACE
Write at 0x0000025ac810 by goroutine 36:
  github.com/AdguardTeam/AdGuardHome/dnsfilter.(*Dnsfilter).checkSafeBrowsing()
      adguard-home/dnsfilter/dnsfilter.go:396 +0x693
  github.com/AdguardTeam/AdGuardHome/dnsfilter.(*Dnsfilter).CheckHost()
      adguard-home/dnsfilter/dnsfilter.go:200 +0xc28
  github.com/AdguardTeam/AdGuardHome/dnsforward.(*Server).filterDNSRequest()
      adguard-home/dnsforward/dnsforward.go:502 +0x4ed
  github.com/AdguardTeam/AdGuardHome/dnsforward.(*Server).handleDNSRequest()
      adguard-home/dnsforward/dnsforward.go:445 +0x167
  github.com/AdguardTeam/AdGuardHome/dnsforward.(*Server).handleDNSRequest-fm()
      adguard-home/dnsforward/dnsforward.go:437 +0x8a
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).handleDNSRequest()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:914 +0xf1c
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).handleUDPPacket()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:625 +0x666
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpPacketLoop.func1()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:593 +0xe9

Previous read at 0x0000025ac810 by goroutine 37:
  github.com/AdguardTeam/AdGuardHome/dnsfilter.(*Dnsfilter).checkSafeBrowsing()
      adguard-home/dnsfilter/dnsfilter.go:395 +0x343
  github.com/AdguardTeam/AdGuardHome/dnsfilter.(*Dnsfilter).CheckHost()
      adguard-home/dnsfilter/dnsfilter.go:200 +0xc28
  github.com/AdguardTeam/AdGuardHome/dnsforward.(*Server).filterDNSRequest()
      adguard-home/dnsforward/dnsforward.go:502 +0x4ed
  github.com/AdguardTeam/AdGuardHome/dnsforward.(*Server).handleDNSRequest()
      adguard-home/dnsforward/dnsforward.go:445 +0x167
  github.com/AdguardTeam/AdGuardHome/dnsforward.(*Server).handleDNSRequest-fm()
      adguard-home/dnsforward/dnsforward.go:437 +0x8a
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).handleDNSRequest()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:914 +0xf1c
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).handleUDPPacket()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:625 +0x666
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpPacketLoop.func1()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:593 +0xe9

Goroutine 36 (running) created at:
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpPacketLoop()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:592 +0x62b

Goroutine 37 (running) created at:
  github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpPacketLoop()
      /Users/ameshkov/Documents/Work/gopath/pkg/mod/github.com/!adguard!team/dnsproxy@v0.14.0/proxy/proxy.go:592 +0x62b
@ameshkov ameshkov added this to the v0.96 milestone Jun 6, 2019
@ameshkov ameshkov modified the milestones: v0.96, v0.97 Jun 6, 2019
@szolin
Copy link
Contributor

szolin commented Jun 7, 2019

This race is a minor issue actually (it does no harm). We just need to remove all lazy initializations like this, and initialize everything properly in New/Create/Init functions.

@szolin szolin closed this as completed in eb8c531 Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants