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

strange termination of program with isolates #7701

Closed
DartBot opened this issue Jan 4, 2013 · 6 comments
Closed

strange termination of program with isolates #7701

DartBot opened this issue Jan 4, 2013 · 6 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-obsolete Closed as the reported issue is no longer relevant

Comments

@DartBot
Copy link

DartBot commented Jan 4, 2013

This issue was originally filed by kguggisberg...@gmail.com


What steps will reproduce the problem?

  1. Run
    library clock;
    import "dart:isolate";

clock() {
  int i=0;
  tick() {
    print("tick ...");
    i++;
    if (i == 2)return;
    new Timer(1000, (timer) => tick());
  }
  new Timer(1000, (timer) => tick());
}

main() {
  spawnFunction(clock);
}

This programs terminates immediately. It doesn't print anything
to the console.

  1. Run the following slight modification (note the commented line at
    the end of main()):

library clock;
import "dart:isolate";

clock() {
  int i=0;
  tick() {
    print("tick ...");
    i++;
    if (i == 2)return;
    new Timer(1000, (timer) => tick());
  }
  new Timer(1000, (timer) => tick());
}

main() {
  spawnFunction(clock);
  // could be var 'p = port', or 'port.receive(null)' or any other
  // expression including receive port 'port'
  port;
}

This program prints
tick ...
tick ...
to the console and doesn't terminate.

What is the expected output? What do you see instead?
It's strange that there has to be an explicit reference to 'port'
only to keep the main isolate alive.

What version of the product are you using? On what operating system?

  • Linux karl-VirtualBox 3.2.0-35-generic-pae #­55-Ubuntu SMP Wed Dec 5 18:04:39 UTC 2012 i686 i686 i386 GNU/Linux
  • Dart VM version: 0.1.2.0_r16645_karl (Fri Jan 4 22:08:18 2013)

Please provide any additional information below.

@DartBot
Copy link
Author

DartBot commented Jan 15, 2013

This comment was originally written by ngeoffray@google.com


How are you running the program? Are you using dartium, chrome, the VM or dart2js?

@DartBot
Copy link
Author

DartBot commented Jan 15, 2013

This comment was originally written by kguggisbe...@gmail.com


I'm using the VM

@anders-sandholm
Copy link
Contributor

Added Area-VM, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jan 29, 2013

This comment was originally written by TerryMitsuoka...@gmail.com


It seems to be another problem of Timer in isolate. Replacing new Timer(1000, (timer) => tick()); with tick(); causes no problem.
Following code also runs well on VM and dart2js but not in Dartium.
new Timer (and new Timer.repeating) terminates the isolate in Dartium ( http://code.google.com/p/dart/issues/detail?id=4997 ).

import "dart:isolate";
import "dart:async";

clock() {
  int i=0;
  tick() {
    print("tick ...");
    i++;
    if (i == 2)return;
    new Timer(1000, (timer) => tick());
  }
  new Timer(1000, (timer) => tick());
}

main() {
  spawnFunction(clock).send('ping', port.toSendPort());
}

@iposva-google
Copy link
Contributor

Removed Priority-Medium label.
Added Priority-Unassigned label.

@lrhn
Copy link
Member

lrhn commented Oct 29, 2014

The implicit "port" no longer exists.
The VM still terminates when the main isolate terminates, but that's another issue.


Added AssumedStale label.

@DartBot DartBot added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-obsolete Closed as the reported issue is no longer relevant labels Oct 29, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-obsolete Closed as the reported issue is no longer relevant
Projects
None yet
Development

No branches or pull requests

4 participants