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

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

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

Comments

@maxim-saplin
Copy link

maxim-saplin commented Nov 11, 2021

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
@maxim-saplin maxim-saplin changed the title Native error with when spawnUir() isolate communicated back to main isolate Native error when isolate created with spawnUri() communicates back to main isolate Nov 11, 2021
@aam
Copy link
Contributor

aam commented Nov 12, 2021

Thanks @maxim-saplin for filing the bug.
https://dart-review.googlesource.com/c/sdk/+/220066 should fix the crash.
Note though that sending instances of _PooledIsolateParams from spawnUri'ed isolates won't work. As written the test will be simply timing out, those errors are not reported because spawnUri invocation specifies errorsAreFatal: false.

@maxim-saplin
Copy link
Author

@aam thanks for prompt reaction, appreciated! BTW, how can I track if a certain issue filed on GitHub or commited to Googlesource lands stable version?

@aam
Copy link
Contributor

aam commented Nov 12, 2021

@maxim-saplin I'm not aware of an automated mechanism that tracks this.
Once the dart-review.googlesource.com change lands you can see which tag it is included in(triple-dots, Included In).
'.dev' tags are normally rolled into flutter/engine at regular several-times-a-day-cadence.
Putting hot-fixes aside, flutter stable is cut once a quarter(https://github.com/flutter/flutter/wiki/Flutter-build-release-channels). You would have to look at hash the stable was cut at, what latest dart sdk dev hash that was included into it, to determine whether particular change is included with that.

@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 12, 2021
@mkustermann
Copy link
Member

Thanks for the bug report @maxim-saplin & @aam for the fix!

I've filed #47696 to get this cherry-picked.

copybara-service bot pushed a commit that referenced this issue Nov 17, 2021
Fixes #47674

TEST=send_object_to_spawn_uri_isolate_test.dart

Change-Id: I96d81df5edbac3054220348be8654250246cad8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220066
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
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, 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