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

4.x: Fix long sequence ObserveOn StackOverflowException upon Dispose #738

Merged
merged 1 commit into from
Jul 3, 2018

Conversation

akarnokd
Copy link
Collaborator

@akarnokd akarnokd commented Jul 3, 2018

This PR fixes the StackOverflowException when a long running ObserveOn (> 100.000 items) gets disposed due to the ScheduledItems linked together when using the recursive scheduler.

The fix is to track the next recursive task's disposable directly and not allow the chaining to happen. For reference, this is the same effect that had to be considered in the improved Range and ToObservable implementations.

// Don't return the disposable of Schedule() because that may chain together
// a long string of ScheduledItems causing StackOverflowException upon Dispose()
var d = recursiveScheduler.Schedule(this, DRAIN_SHORT_RUNNING);
Disposable.TrySetMultiple(ref _task, d);
}
return Disposable.Empty;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it at least return this here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would recurse upon calling Dispose() for no practical purpose. The public void Dispose() takes care of the cleanup when the downstream disposes, including the outstanding tasks.

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.

2 participants