Skip to content

Commit b67a585

Browse files
aamcommit-bot@chromium.org
authored andcommitted
[vm/isolate] Provide more verbose information when second mutator thread attempts to enter an isolate.
This should help with troubleshooting vm crashes caused by multiple mutator threads entering an isolate. TEST=flutter/engine runtime_unittests that exhibits this flaky problem with DartIsolateTest.ValidLoadingUnitSucceeds Change-Id: Ib503df844cceafa58882a695a1fe7ceaa88eaed4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174900 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Siva Annamalai <asiva@google.com>
1 parent 9a82c54 commit b67a585

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

runtime/vm/dart_api_impl.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,10 +1700,16 @@ DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate) {
17001700
// TODO(http://dartbug.com/16615): Validate isolate parameter.
17011701
Isolate* iso = reinterpret_cast<Isolate*>(isolate);
17021702
if (!Thread::EnterIsolate(iso)) {
1703-
FATAL(
1704-
"Unable to Enter Isolate : "
1705-
"Multiple mutators entering an isolate / "
1706-
"Dart VM is shutting down");
1703+
if (iso->IsScheduled()) {
1704+
FATAL(
1705+
"Isolate %s is already scheduled on mutator thread %p, "
1706+
"failed to schedule from os thread 0x%" Px "\n",
1707+
iso->name(), iso->scheduled_mutator_thread(),
1708+
OSThread::ThreadIdToIntPtr(OSThread::GetCurrentThreadId()));
1709+
} else {
1710+
FATAL("Unable to enter isolate %s as Dart VM is shutting down",
1711+
iso->name());
1712+
}
17071713
}
17081714
// A Thread structure has been associated to the thread, we do the
17091715
// safepoint transition explicitly here instead of using the

runtime/vm/isolate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry<Isolate> {
812812
return thread == nullptr ? nullptr : thread->isolate();
813813
}
814814

815-
bool IsScheduled() { return scheduled_mutator_thread_ != nullptr; }
815+
bool IsScheduled() { return scheduled_mutator_thread() != nullptr; }
816+
Thread* scheduled_mutator_thread() const { return scheduled_mutator_thread_; }
816817

817818
// Register a newly introduced class.
818819
void RegisterClass(const Class& cls);

0 commit comments

Comments
 (0)