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

Data races in the example #7

Closed
hnakamur opened this issue Jun 28, 2017 · 1 comment
Closed

Data races in the example #7

hnakamur opened this issue Jun 28, 2017 · 1 comment

Comments

@hnakamur
Copy link
Contributor

I got 2 data races when I ran the example modified in Set Destination AddressFamily in example by hnakamur · Pull Request #6 · mqliang/libipvs.

$ go build -race
$ sudo ./example
==================
WARNING: DATA RACE
Write at 0x00c4200c6090 by goroutine 7:
  runtime.mapassign()
      /usr/local/go/src/runtime/hashmap.go:521 +0x0
  github.com/hkwi/nlgo.GenlHub.GenlListen()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:237 +0x3c3
  github.com/hkwi/nlgo.(*GenlHub).GenlListen()
      <autogenerated>:1 +0xbb
  github.com/hkwi/nlgo.NewGenlHub.func1()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:161 +0x968

Previous read at 0x00c4200c6090 by main goroutine:
  runtime.mapiterinit()
      /usr/local/go/src/runtime/hashmap.go:709 +0x0
  github.com/hkwi/nlgo.(*GenlHub).Family()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:308 +0x2b6
  github.com/mqliang/libipvs.New()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/ipvs.go:55 +0x3c1
  main.main()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/example/main.go:12 +0x47

Goroutine 7 (running) created at:
  github.com/hkwi/nlgo.NewGenlHub()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:122 +0x92e
  github.com/mqliang/libipvs.New()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/ipvs.go:49 +0x347
  main.main()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/example/main.go:12 +0x47
==================
==================
WARNING: DATA RACE
Write at 0x00c4200cc018 by goroutine 7:
  github.com/hkwi/nlgo.GenlHub.GenlListen()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:237 +0x3e5
  github.com/hkwi/nlgo.(*GenlHub).GenlListen()
      <autogenerated>:1 +0xbb
  github.com/hkwi/nlgo.NewGenlHub.func1()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:161 +0x968

Previous read at 0x00c4200cc018 by main goroutine:
  github.com/hkwi/nlgo.(*GenlHub).Family()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:308 +0x2f4
  github.com/mqliang/libipvs.New()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/ipvs.go:55 +0x3c1
  main.main()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/example/main.go:12 +0x47

Goroutine 7 (running) created at:
  github.com/hkwi/nlgo.NewGenlHub()
      /home/hnakamur/go/src/github.com/hkwi/nlgo/genl_hub.go:122 +0x92e
  github.com/mqliang/libipvs.New()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/ipvs.go:49 +0x347
  main.main()
      /home/hnakamur/go/src/github.com/mqliang/libipvs/example/main.go:12 +0x47
==================
libipvs.Info{Version:0x10201, ConnTabSize:0x1000}
[]*libipvs.Service(nil)
[]*libipvs.Service{(*libipvs.Service)(0xc4200f4090)}
[]*libipvs.Destination{(*libipvs.Destination)(0xc420100080)}
Found 2 data race(s)
@hnakamur
Copy link
Contributor Author

It turns out that this is the problem in github.com/hkwi/nlgo, not in github.com/mqliang/libipvs.

I sent a pull request to fix this problem.
Guard familyIds with lock in GenlHub.Family by hnakamur · Pull Request #3 · hkwi/nlgo

So I'm closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant