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 #1056: ensure boundary in TaskCreate if LCP enabled #1063

merged 1 commit into from Nov 7, 2019


Copy link

oleg-py commented Oct 25, 2019

The optimization bypassing the async boundary can break Local isolation.

The optimization bypassing the async boundary can break Local
@oleg-py oleg-py requested review from alexandru and Avasil Oct 25, 2019
@@ -226,10 +226,11 @@ private[eval] object TaskCreate {
if (shouldPop) ctx.connection.pop()
// Optimization — if the callback was called on the same thread
// where it was created, then we are not going to fork
// This is not safe to do when localContextPropagation enabled

This comment has been minimized.

Copy link

Avasil Oct 30, 2019


Why is it not safe?

This comment has been minimized.

Copy link

oleg-py Oct 31, 2019

Author Collaborator

Because this extends a TrampolinedRunnable, and TracingScheduler extends BatchingScheduler, doing execute bypasses the TracingRunnable creation and context isolation that it has.

Without that isolation, the continuation of that async/asyncF/etc. node therefore will have the context from whoever called the cb, not from where the async was actually created.

That only happened in case cb was called synchronously, but it does happen deep in ConcurrentChannel impl in certain concurrent usage patterns with fast producer and slow-ish consumer.

Avasil approved these changes Nov 5, 2019
@Avasil Avasil merged commit 5f49fb6 into monix:master Nov 7, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.