Sdk: Isolates are not spawned in the latest dart versions

Created on 12 Jun 2016  路  6Comments  路  Source: dart-lang/sdk

When I create Isolates with the LoadBalancer of the isolate package, the execution freezes when I call LoadBalancer.create(...). The problem occurs since dart sdk 1.17.0-dev.3.0. The following example reproduces the issue:

pubspec.yaml:

name: isolate_bug
version: 0.0.1
description: A simple console application.
dependencies:
  isolate: any
  test: any

main.dart:

import 'package:test/test.dart';
import 'package:isolate/isolate.dart';

main() async {
  test('Load Balancer Freeze', () async {
    final loadBalancer = await LoadBalancer.create(1, IsolateRunner.spawn);
  });
}

Hint: If I change a line in isolate_runner.dart from await Isolate.spawn(IsolateRunnerRemote._create to await Isolate.spawn(IsolateRunnerRemote.create (and add static void create(SendPort initPort) => _create(initPort); to IsolateRunnerRemote) the code executes correctly. Looks like isolates have problems finding private methods. However, I didn't manage to reproduce the problem independently of the isolate package.

Hint 2: We call await IsolateRunner:run(...) and reference a private class method in our code. This call is also never completed. It works if we change the method from private to public.

Current dart version: Dart VM version: 1.18.0-dev.0.0 (Wed Jun 08 02:16:50 2016) on "windows_x64"

Update: A large number of tests in the isolate package fail for the same SDK versions and the same reason.

area-vm type-bug

Most helpful comment

All 6 comments

I've also been trying to isolate this particular bug, as we've seen many of our automated tests start failing intermittently, because our logger operates on a separate isolate. The test runner stalls on await Isolate.spawn(...), and no amount of pausing/resuming/error/exit listeners changes that - it simply just never returns.

I can also confirm that Hint 2 seems to be an important point. Our applications import a logging library where the entry method is private to the imported library. If I move the entry point into the application package, it works fine.

I believe this is a regression caused by a small change we made to how the private key value of a library is computed in this CL https://codereview.chromium.org/1947393003/

Thanks for your fix. It solves one part of our problem (await Isolate.spawn(...) now also works with private methods). But when I call run(_somePrivateFunction, args) of an IsolateRunner instance in our project (and thus send a private method via a SendPort) it stalls again.

Sorry missed your comment, will take a look at this.

It looks like the problem has been fixed in the recent releases of the SDK. Thus this issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xster picture xster  路  3Comments

DartBot picture DartBot  路  3Comments

DartBot picture DartBot  路  3Comments

brooth picture brooth  路  3Comments

DartBot picture DartBot  路  3Comments