Closed daenney closed 4 years ago
I'm using dnssd in a project of mine and I run my tests with the race detector. This surfaced a race in dnssd:
================== WARNING: DATA RACE Write at 0x00c00029e0b7 by goroutine 31: github.com/brutella/dnssd.(*mdnsConn).readInto.func3() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/mdns.go:260 +0x63 Previous read at 0x00c00029e0b7 by goroutine 29: github.com/brutella/dnssd.(*mdnsConn).readInto.func1() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/mdns.go:188 +0x7f Goroutine 31 (running) created at: github.com/brutella/dnssd.(*mdnsConn).readInto() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/mdns.go:258 +0xc7 github.com/brutella/dnssd.(*mdnsConn).Drain() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/mdns.go:178 +0x1e3 github.com/brutella/dnssd.probeAtInterface() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:163 +0x9fa github.com/brutella/dnssd.probe() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:114 +0x441 github.com/brutella/dnssd.probeService() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:61 +0x3ae github.com/brutella/dnssd.ProbeService() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:38 +0x43d github.com/brutella/dnssd.(*responder).register() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/responder.go:185 +0x481 github.com/brutella/dnssd.(*responder).Respond() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/responder.go:104 +0x20b github.com/hemtjanst/fargton/bridge.(*Server).Start.func4() /home/daenney/Development/github.com/hemtjanst/fargton/bridge/server.go:226 +0x6e Goroutine 29 (running) created at: github.com/brutella/dnssd.(*mdnsConn).readInto() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/mdns.go:185 +0x13a github.com/brutella/dnssd.(*mdnsConn).Drain() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/mdns.go:178 +0x1e3 github.com/brutella/dnssd.probeAtInterface() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:163 +0x9fa github.com/brutella/dnssd.probe() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:114 +0x441 github.com/brutella/dnssd.probeService() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:61 +0x3ae github.com/brutella/dnssd.ProbeService() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/probe.go:38 +0x43d github.com/brutella/dnssd.(*responder).register() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/responder.go:185 +0x481 github.com/brutella/dnssd.(*responder).Respond() /home/daenney/Development/go/pkg/mod/github.com/brutella/dnssd@v1.1.0/responder.go:104 +0x20b github.com/hemtjanst/fargton/bridge.(*Server).Start.func4() /home/daenney/Development/github.com/hemtjanst/fargton/bridge/server.go:226 +0x6e ==================
This happens b/c the isReading var in readInto needs a lock around it to ensure it can safely be modified.
isReading
readInto
Should be fixed now
I'm using dnssd in a project of mine and I run my tests with the race detector. This surfaced a race in dnssd:
This happens b/c the
isReading
var inreadInto
needs a lock around it to ensure it can safely be modified.