Do not handle Dart isolate messages if the isolate is being shut down#57081
Do not handle Dart isolate messages if the isolate is being shut down#57081jason-simmons wants to merge 1 commit intoflutter:mainfrom
Conversation
This fixes a race that can happen if Dart invokes an isolate's message handling callback during isolate shutdown. The callback installed by Tonic will invoke a dispatcher set by the engine's DartIsolate::SetMessageHandlingTaskRunner, which will queue a message handling task to the designated task runner. If the queued task runs after DartIsolate::Shutdown has been called, then Tonic's DartMessageHandler::OnHandleMessage will fail when it tries to enter the isolate. DartIsolate will set a shutdown flag on the DartState when Dart invokes the isolate's shutdown callback. Tonic can avoid this race by checking that flag before proceeding with message handling. Fixes flutter/flutter#160003
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
@chinmaygarde friendly ping. The code looks good but it's hard to know if there are any potential ramifications we aren't considering. If we are unsure we should take a cue from the tests and accept it. |
|
(Also obligatory call for a test) |
Monorepo Migration Completed
The
This is a canned message |
This fixes a race that can happen if Dart invokes an isolate's message handling callback during isolate shutdown. The callback installed by Tonic will invoke a dispatcher set by the engine's DartIsolate::SetMessageHandlingTaskRunner, which will queue a message handling task to the designated task runner.
If the queued task runs after DartIsolate::Shutdown has been called, then Tonic's DartMessageHandler::OnHandleMessage will fail when it tries to enter the isolate.
DartIsolate will set a shutdown flag on the DartState when Dart invokes the isolate's shutdown callback. Tonic can avoid this race by checking that flag before proceeding with message handling.
Fixes flutter/flutter#160003