Skip to content

Native error when isolate created with spawnUri() communicates back to main isolate #47674

@maxim-saplin

Description

@maxim-saplin

Dart SDK version: 2.14.4 (stable) (Wed Oct 13 11:11:32 2021 +0200) on "macos_x64"

CCing @aam

Steps to reproduce:

  1. Clone https://github.com/maxim-saplin/ikvpack/tree/spawnUri (make sure it is spawnUri branch)
  2. Run isolate related tests: dart test test/isolate_pooled_instance_test.dart

Actuals:
Test run is halted with the following output:

00:01 +0: [VM] Creating pooled instance succeeds                                                                                 
Creating a pool of 4 running isolates
0
Isolate #0 started (0 microseconds)
../../runtime/vm/message_snapshot.cc: 557: error: expected: !cls.IsNull()
version=2.14.4 (stable) (Wed Oct 13 11:11:32 2021 +0200) on "macos_x64"
pid=8373, thread=21255, isolate_group=main(0x7f864b822e00), isolate=main(0x7f864b889a00)
isolate_instructions=109ff10a0, vm_instructions=109ff10a0
  pc 0x000000010a259154 fp 0x00007000071aeb00 dart::Profiler::DumpStackTrace(void*)+0x64
  pc 0x0000000109ff1274 fp 0x00007000071aebe0 dart::Assert::Fail(char const*, ...)+0x84
  pc 0x000000010a1bd71a fp 0x00007000071aec40 dart::ReadApiMessage(dart::Zone*, dart::Message*)+0x896a
  pc 0x000000010a1b4334 fp 0x00007000071aecb0 dart::MessageDeserializer::Deserialize()+0x274
  pc 0x000000010a1b4d6f fp 0x00007000071aed00 dart::ReadMessage(dart::Thread*, dart::Message*)+0x5f
  pc 0x000000010a1829c9 fp 0x00007000071aede0 dart::IsolateMessageHandler::HandleMessage(std::__2::unique_ptr<dart::Message, std::__2::default_delete<dart::Message> >)+0x1a9
  pc 0x000000010a1afd4c fp 0x00007000071aee50 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)+0x12c
  pc 0x000000010a1b047f fp 0x00007000071aeeb0 dart::MessageHandler::TaskCallback()+0x1df
  pc 0x000000010a2e3bd8 fp 0x00007000071aef30 dart::ThreadPool::WorkerLoop(dart::ThreadPool::Worker*)+0x148
  pc 0x000000010a2e403d fp 0x00007000071aef60 dart::ThreadPool::Worker::Main(unsigned long)+0x5d
  pc 0x000000010a253b1f fp 0x00007000071aefb0 dart::OSThread::GetMaxStackSize()+0xaf
  pc 0x00007ff818400514 fp 0x00007000071aefd0 _pthread_start+0x7d
  pc 0x00007ff8183fc02f fp 0x00007000071aeff0 thread_start+0xf
-- End of DumpStackTrace
/Users/maxim/flutter/bin/internal/shared.sh: line 225:  8373 Abort trap: 6           "$DART" "$@"

Expected:
All is good.

Comments in regards to the code

  1. The branch was created to try spawnUri() as a workaround for the troubles caused due to Isolates Groups turned on by default for spawn() (Performance degradation after upgrading to newer Flutter with Isolate Groups enabled by default #47672)
  2. This is the line were isolates are spawned, all is fine in Debugger at this point: https://github.com/maxim-saplin/ikvpack/blob/93dcd6ab9551570a655913676d14c47481700502/lib/src/isolate_helpers.dart#L232
  3. Isolates are successfully started (line 410) and they seem to be able to send responses to main isolate without any errors (line 422)
  4. Main isolate is supposed to listen to isolates' incoming message at line 238, though it seems a native crash happens before any messages can arrive here

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions