vjeantet / ldapserver

Package ldapserver implements LDAP Server
MIT License
250 stars 93 forks source link

WARNING: DATA RACE in client #25

Open tamalsaha opened 6 years ago

tamalsaha commented 6 years ago
WARNING: DATA RACE
Write at 0x00c420282844 by goroutine 65:
  internal/race.Write()
      /home/travis/.gimme/versions/go1.10.3.linux.amd64/src/internal/race/race.go:41 +0x38
  sync.(*WaitGroup).Wait()
      /home/travis/.gimme/versions/go1.10.3.linux.amd64/src/sync/waitgroup.go:127 +0xf3
  github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver.(*client).close()
      /home/travis/gopath/src/github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver/client.go:188 +0x671
  github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver.(*client).serve()
      /home/travis/gopath/src/github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver/client.go:124 +0xa69
Previous read at 0x00c420282844 by goroutine 67:
  internal/race.Read()
      /home/travis/.gimme/versions/go1.10.3.linux.amd64/src/internal/race/race.go:37 +0x38
  sync.(*WaitGroup).Add()
      /home/travis/.gimme/versions/go1.10.3.linux.amd64/src/sync/waitgroup.go:70 +0x16e
  github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver.(*client).serve.func2()
      /home/travis/gopath/src/github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver/client.go:88 +0x18c
Goroutine 65 (running) created at:
  github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver.(*Server).serve()
      /home/travis/gopath/src/github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver/server.go:110 +0x4e7
  github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver.(*Server).ListenAndServe()
      /home/travis/gopath/src/github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver/server.go:63 +0x258
  github.com/appscode/guard/auth/providers/ldap.(*ldapServer).start()
      /home/travis/gopath/src/github.com/appscode/guard/auth/providers/ldap/ldap_test.go:46 +0x261
Goroutine 67 (running) created at:
  github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver.(*client).serve()
      /home/travis/gopath/src/github.com/appscode/guard/vendor/github.com/vjeantet/ldapserver/client.go:84 +0x23c
tamalsaha commented 6 years ago

This feels like an incorrect use of Waitgroup https://github.com/golang/go/issues/8054#issuecomment-66095150 you wg.Wait before all root wg.Add's. .

tamalsaha commented 6 years ago

It seems https://github.com/vjeantet/ldapserver/blob/master/client.go#L88 is getting called after https://github.com/vjeantet/ldapserver/blob/master/client.go#L60 . Any ideas on how to fix this?