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

Documentation of Isolate.spawn is incomplete #15234

Closed
DartBot opened this issue Nov 21, 2013 · 4 comments
Closed

Documentation of Isolate.spawn is incomplete #15234

DartBot opened this issue Nov 21, 2013 · 4 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Nov 21, 2013

This issue was originally filed by alexe.kaigorodov@gmail.com


The description of the static method Isolate.spawn reads:

It must be a top-level function or a static method that takes one argument - that is, one-parameter functions that can be compile-time constant function values. It is not allowed to pass the value of function expressions or an instance method extracted from an object.

It is not said what happens if the argument is not a compile-time constant function. Now an error message like "in ShutdownIsolate: Unable to resolve function 'f' in library" is printed, and the program hangs. Evidently, hanging is not a best behaviour, but I cannot file a bug against dart vm because formally it is allowed.

@lrhn
Copy link
Member

lrhn commented Nov 21, 2013

The VM should detect this earlier, and throw an ArgumentError.
I recently changed the argument validation code on bleeding edge, so maybe the problem is already fixed, or there may be some cases that slip through the detection. The error message looks like the old one.
Can you describe the function you use?


Added Area-VM, NeedsInfo labels.

@DartBot
Copy link
Author

DartBot commented Nov 22, 2013

This comment was originally written by alexe.kaigorodov@gmail.com


see co19 test LibTest/isolate/Isolate/spawn_A02_t01 from https://code.google.com/p/co19/source/detail?r=669 . Remove "return" statement from the middle of the text to enable the test.

@DartBot
Copy link
Author

DartBot commented Jan 22, 2014

This comment was originally written by alexe.kaigorodov@gmail.com


An Error is thrown, but not at the place of invokation:

main() {
  void f(SendPort replyPort) {
    replyPort.send("justas");
  }

  var receivePort = new ReceivePort();

  try {
    Isolate.spawn(f, receivePort.sendPort);
    print("no exception");
  } catch(e) {
    print("exception: $e");
  }
}

gives:

no exception
Uncaught Error: Illegal argument(s): Isolate.spawn expects to be passed a static or top-level function
Stack Trace:
#­0 Isolate._spawnFunction (dart:isolate-patch/isolate_patch.dart:272)
#­1 Isolate.spawn (dart:isolate-patch/isolate_patch.dart:233)
#­2 main (file:///home/kaigorodov/dash/dash/co19/tests/co19/src/LibTest/isolate/Isolate/spawn_A02_t01.dart:29:18)
#­3 _startIsolate.isolateStartHandler (dart:isolate-patch/isolate_patch.dart:216)
#­4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:115)

Unhandled exception:
Illegal argument(s): Isolate.spawn expects to be passed a static or top-level function
#­0 _rootHandleUncaughtError.<anonymous closure>.<anonymous closure> (dart:async/zone.dart:677)
#­1 _asyncRunCallback (dart:async/schedule_microtask.dart:18)
#­2 _asyncRunCallback (dart:async/schedule_microtask.dart:21)
#­3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:119)

Validation should be performed as soon as possible, in the Isolate.spawn() function.

@DartBot DartBot added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. needs-info We need additional information from the issue author (auto-closed after 14 days if no response) labels Jan 22, 2014
@srawlins srawlins removed the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Jan 18, 2016
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@srawlins
Copy link
Member

The VM now does throw an argument error, at the line of Isolate.spawn (4th frame of the stack).

$ dart --version
Dart VM version: 2.0.0-dev.63.0 (Fri Jun 15 00:42:43 2018 +0200) on "macos_x64"
$ cat 15234.dart 
import 'dart:isolate';

main() {
  void f(SendPort replyPort) {
    replyPort.send("justas");
  }

  var receivePort = new ReceivePort();

  try {
    Isolate.spawn(f, receivePort.sendPort);
    print("no exception");
  } catch(e) {
    print("exception: $e");
  }
}
$ dart --preview-dart-2 15234.dart 
no exception
Unhandled exception:
Invalid argument(s): Isolate.spawn expects to be passed a static or top-level function
#0      Isolate._spawnFunction (dart:isolate/runtime/libisolate_patch.dart:506:59)
#1      Isolate.spawn (dart:isolate/runtime/libisolate_patch.dart:359:7)
<asynchronous suspension>
#2      main (file:///Users/srawlins/code/15234.dart:11:13)
#3      _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
#4      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)

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

No branches or pull requests

4 participants