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

VM terminates when initial isolate ends, even if other isolates are still running. #4229

Open
justinfagnani opened this issue Jul 27, 2012 · 4 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-l P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@justinfagnani
Copy link
Contributor

Isolates should run and keep the VM open while they execute even if the parent idolate does not send a message or create a ReceivePort.

This sample only prints "test" when the ReceivePort is created. However, due to 3761, the Isolate then never terminates.

import('dart:io');

import('dart:isolate');

void main() {
  ReceivePort receivePort = new ReceivePort(); // needed to keep the VM running
  SendPort sendPort = spawnFunction(test);
}

void test() {
  print("test");
}

This program doesn't print "test" or "hi" unless a ReceivePort is created in the parent Isolate.

void main() {
  SendPort sendPort = spawnFunction(test);
  sendPort.send("hi");
}

void test() {
  port.receive((m, p) => print(m));
  print("test");
}

@dgrove
Copy link
Contributor

dgrove commented Jul 29, 2012

cc @turnidge.
cc @sigmundch.
Added Area-Library, Triaged labels.

@turnidge
Copy link
Contributor

Set owner to @turnidge.

@turnidge
Copy link
Contributor

turnidge commented Aug 6, 2012

Well, this is the way that the feature was designed. The main isolate is special. I agree that it is confusing. I am changing this from Type-Defect to Type-Enhancement.


Removed Type-Defect label.
Added Type-Enhancement label.

@lrhn
Copy link
Member

lrhn commented Oct 29, 2014

I'm not sure where the isolates are specified to behave this way, and I don't think it's a good idea to make the main isolate special. The VM could stay alive as long as any isolate is alive and waiting, and dart2js code is currently doing that.
Example:

import "dart:isolate";
import "dart:async";
main() { Isolate.spawn(second, null); }
void second(_) {
  new Timer(const Duration(seconds: 2), () { print("Goodbye"); });
}

This prints "Goodbye" when compiled with dart2js, but nothing when run with the Dart VM.

So: I suggest implementing this enhancement and changing the VM behavior.

@justinfagnani justinfagnani added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Oct 29, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Feb 29, 2016
@lrhn lrhn changed the title Isolates terminate early VM terminates when initial isolate ends, even if other isolates are still running. Aug 11, 2017
@lrhn lrhn added the core-m label Aug 11, 2017
@floitschG floitschG added core-l and removed core-m labels Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-l P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants