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 race in state.go:1135 #306

Open
vitalif opened this issue Jul 22, 2024 · 1 comment
Open

Data race in state.go:1135 #306

vitalif opened this issue Jul 22, 2024 · 1 comment

Comments

@vitalif
Copy link

vitalif commented Jul 22, 2024

Hi. I've detected the following data race in memberlist 0.5.0:

==================
WARNING: DATA RACE
Write at 0x00c000693728 by goroutine 53:
  github.com/hashicorp/memberlist.(*Memberlist).aliveNode()
      .../vendor/github.com/hashicorp/memberlist/state.go:1135 +0x2e3b
  github.com/hashicorp/memberlist.(*Memberlist).handleAlive()
      .../vendor/github.com/hashicorp/memberlist/net.go:738 +0x69a
  github.com/hashicorp/memberlist.(*Memberlist).packetHandler()
      .../vendor/github.com/hashicorp/memberlist/net.go:513 +0x1b9
  github.com/hashicorp/memberlist.newMemberlist.gowrap3()
      .../vendor/github.com/hashicorp/memberlist/memberlist.go:235 +0x33

Previous read at 0x00c000693728 by goroutine 146:
  github.com/hashicorp/memberlist.(*Node).Address()
      .../vendor/github.com/hashicorp/memberlist/state.go:58 +0x6b
...

Goroutine 53 (running) created at:
  github.com/hashicorp/memberlist.newMemberlist()
      .../vendor/github.com/hashicorp/memberlist/memberlist.go:235 +0x1aea
  github.com/hashicorp/memberlist.Create()
      .../vendor/github.com/hashicorp/memberlist/memberlist.go:246 +0x2e
...

Goroutine 146 (running) created at:
...
==================

The idea is that memberlist Members() returns a list of pointers to Memberlist::nodes array items. Then the external user's code is allowed to read them without any locking. But at the same time, they may get modified internally in Memberlist, resulting in a data race.

Not sure if it's a critical issue and how hard it would be to stumble on it in production. But it's still a race...

@vitalif
Copy link
Author

vitalif commented Jul 22, 2024

May be related to #272 but I'm not sure.

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