-
Notifications
You must be signed in to change notification settings - Fork 802
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 #645
Comments
Also see, 42wim/matterbridge#815 |
Would replacing the Member in MemberAdd() work? As opposed to updating the one we have in place. e.g.: diff --git a/state.go b/state.go
index e6f08c7..91cb7e0 100644
--- a/state.go
+++ b/state.go
@@ -308,7 +308,8 @@ func (s *State) MemberAdd(member *Member) error {
if member.JoinedAt == "" {
member.JoinedAt = m.JoinedAt
}
- *m = *member
+ members[member.User.ID] = member
+ // TODO update guild.Members
}
return nil |
So there's a couple of issues here, which took me a few mins to figure out since it's been so long, the traces here are pointing to the wrong lines. Sorry it's been this long before I could get to this. In the race from the matterbridge issue 42wim/matterbridge#815
Since all these actions ended up looking at a pointer to the same item - we have a data race. To fix this, the Presence update in DiscordGo should make a new copy of Member and write a pointer of that back into the State as @horgh recommends. Which has the side effect that in the above case, by the time Matterbridge started looking at the new member, it's data will have already been updated/changed in DiscordGo state. Then we have the data race trace in this ticket right here, which is pretty much the same it's just getting caught at different points. I'll submit a proposed PR later today/tomorrow for this. |
I've created a branch for this with a partial fix, we need to figure out how to properly update guild.Members and I haven't thought up a good way yet. Because there would be data race issues there as well, I believe. Might be that we have to make a copy of it too so that's probably what I'll do for now, and maybe we can come up with a more efficient way later. |
After reviewing this a bit more, I think the problem is a big bigger than just MemberAdd. I'm going to close this in favour of #731 in which I'll try to find a more global fix to the problem. |
The text was updated successfully, but these errors were encountered: