Skip to content

Incorrect isolate test tests/lib_2/isolate/ping_pause_test.dart ? #37787

@mkustermann

Description

@mkustermann

From tests/lib_2/isolate/ping_pause_test.dart:

isomain1(replyPort) {
  RawReceivePort port = new RawReceivePort();
  port.handler = (v) {
    replyPort.send(v);
    if (v == 0) port.close();
  };
  replyPort.send(port.sendPort);
}

void main() {
  asyncStart();
  var completer = new Completer(); // Completed by first reply from isolate.
  RawReceivePort reply = new RawReceivePort(completer.complete);
  Isolate.spawn(isomain1, reply.sendPort).then((Isolate isolate) {
    List result = [];
    completer.future.then((echoPort) {
      reply.handler = (v) {
        result.add(v);
        if (v == 0) {
          Expect.listEquals([4, 3, 2, 1, 0], result);
          reply.close();
          asyncEnd();
        }
      };
      echoPort.send(4);
      echoPort.send(3);
      Capability resume = isolate.pause();
      var pingPort = new RawReceivePort();
      pingPort.handler = (_) {
        Expect.isTrue(result.length <= 2);
        echoPort.send(0);
        isolate.resume(resume);
        pingPort.close();
      };
      isolate.ping(pingPort.sendPort, priority: Isolate.beforeNextEvent);
      echoPort.send(2);
      echoPort.send(1);
    });
  });
}

This test seems to be currently just timing out on most / all configurations.

When looking closer at this test it seems that the main isolate is pausing isomain1 and after that one is being paused it sends it a ping. Though the ping is sent via Isolate.beforeNextEvent which causes us to enqueue it into the normal message queue, not in the OOB queue.

Though since the isolate is paused it will not process any more messages from the normal queue. So the ping will not get answered.

Yet the main isolate needs the ping to get answered before it will resume the other isolate.

=> We are "deadlocked" - none of the two isolates makes progress.

I'm going to skip this test for now.

Metadata

Metadata

Assignees

Labels

area-testCross-cutting test issues (use area- labels for specific failures; not used for package:test).gardening

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions