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

Invalid Isolate arguments throw uncatchable errors #28041

Closed
nex3 opened this issue Dec 8, 2016 · 3 comments
Closed

Invalid Isolate arguments throw uncatchable errors #28041

nex3 opened this issue Dec 8, 2016 · 3 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@nex3
Copy link
Member

nex3 commented Dec 8, 2016

When you try to send an illegal object across isolate boundaries, Dart currently top-levels an exception. I'd expect it to throw synchronously on the call to SendPort.add(). The current behavior makes it extremely difficult to tell where the illegal object is coming from or to gracefully handle the error.

For example:

import 'dart:async';
import 'dart:isolate';

main() {
  Isolate.spawnUri(new Uri.dataFromString(r"""
    import "dart:isolate";

    void main(_, SendPort port) {
      runZoned(() {
        try {
          port.send([].iterator);
        } catch (error) {
          print("caught sync $error");
        }
      }, onError: (error) {
        print("caught async $error");
      });
    }
  """), [], new ReceivePort());
}

See also #18593.

@nex3 nex3 added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Dec 8, 2016
@kevmoo kevmoo added the S1 high label Dec 8, 2016
@floitschG
Copy link
Contributor

Why was this marked as S1?

I can't reproduce.
Once I fixed the code to not fail in the main isolate (by sending new ReceivePort().sendPort), and after I fixed the spawned isolate to also import dart:async (for the runZoned) I correctly get:

caught sync Invalid argument(s): Illegal argument in isolate message : (object is a regular Dart Instance).

Uncaught errors in non-main isolates are not printed in the VM: #26626

Note that the onError argument correctly prints the error.

import 'dart:async';
import 'dart:isolate';

main() {
  var rp = new ReceivePort();
  rp.listen(print);
  Isolate.spawnUri(new Uri.dataFromString(r"""
    import "dart:isolate";
    import "dart:async";

    void main(_, SendPort port) {
      runZoned(() {
        try {
          port.send([].iterator);
        } catch (error) {
          print("caught sync $error");
        }
      }, onError: (error) {
        print("caught async $error");
      });
    }
  """), [], rp.sendPort, onError: rp.sendPort);
}

@kevmoo
Copy link
Member

kevmoo commented Dec 9, 2016

I marked it S1 because I was told it would be difficult to impossible to debug/diagnose

@nex3
Copy link
Member Author

nex3 commented Dec 12, 2016

Sorry, my mistake!

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. library-isolate type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants