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

Fix race condition issue in combineLatest #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AdamPitt7
Copy link

This is to fix a race condition in the combineLatest function.
I was getting nil pointer exceptions when using combineLatest callback function f FuncN with multiple observables which are also using combineLatest.

From what I can tell, the race condition is caused when one observable has incremented the counter, but has not yet set the cache variable s[i] = item.V
Meanwhile, another observable is checking if the counter is equal to the number of observables atomic.LoadUint32(&counter) == size and then calling the callback function with the cache variable which now includes a nil value.

By moving the counter increment into the lock, this should fix the race condition issue.

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

Successfully merging this pull request may close these issues.

1 participant