Skip to content

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