You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The sequence of events that reproduces the bug is:
Main isolate starts
Main isolate spawns other isolates
Other isolates pause, are collected, and exit
IsolatePausedListener._allNonMainIsolatesExited is completed, so IsolatePausedListener.waitUntilAllExited starts waiting on IsolatePausedListener._mainIsolatePaused.
Main isolate spawns more isolates
Main isolate pauses
IsolatePausedListener._mainIsolatePaused is completed, so IsolatePausedListener.waitUntilAllExited collects and resumes the main isolate
The main isolate has exited, so the VM shuts down, and the VM service connection is disposed
The remaining isolates pause, so IsolatePausedListener tries to collect and resume them, causing the exception seen in the bug.
Step 5 is the bit I didn't consider when writing the new flow. The fix is just to make _allNonMainIsolatesExited wait for main to pause (logically this future is now _allNonMainIsolatesExitedAndMainIsolatePaused, but that's a bit verbose).
Details:
We're already calling _checkCompleted() when main is paused (to fix a different edge case), so we're still going to complete the _allNonMainIsolatesExited future even if all the non-main isolates exit before main pauses.
In some sequences (see test), the other isolates in main's group are collected before main, so main's _runCallbackAndResume() call now has to check if main's group has already been collected.
This check for test coverage is informational (issues shown here will not fail the PR).
API leaks ✔️
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
Package
Leaked API symbols
License Headers ✔️
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sequence of events that reproduces the bug is:
IsolatePausedListener._allNonMainIsolatesExited
is completed, soIsolatePausedListener.waitUntilAllExited
starts waiting onIsolatePausedListener._mainIsolatePaused
.IsolatePausedListener._mainIsolatePaused
is completed, soIsolatePausedListener.waitUntilAllExited
collects and resumes the main isolateIsolatePausedListener
tries to collect and resume them, causing the exception seen in the bug.Step 5 is the bit I didn't consider when writing the new flow. The fix is just to make
_allNonMainIsolatesExited
wait for main to pause (logically this future is now_allNonMainIsolatesExitedAndMainIsolatePaused
, but that's a bit verbose).Details:
_checkCompleted()
when main is paused (to fix a different edge case), so we're still going to complete the_allNonMainIsolatesExited
future even if all the non-main isolates exit before main pauses._runCallbackAndResume()
call now has to check if main's group has already been collected.Fixes #685