[vm] Avoid deadlock in Isolate.debugName.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62237
Change-Id: I57bfcc341e34aa9e873092e0f7ebf44bc2f95cfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476143
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Ryan Macnak
2026-01-28 11:10:42 -08:00
committed by Commit Queue
parent 98f6c3831b
commit f2e1df1997
2 changed files with 24 additions and 4 deletions
@@ -0,0 +1,24 @@
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:isolate';
child(replyPort) {
for (var i = 0; i < 10; i++) {
replyPort.send(Isolate.current.debugName);
}
}
main() async {
var pending = 0;
var port = new RawReceivePort();
port.handler = (_) {
pending--;
if (pending == 0) port.close();
};
for (var i = 0; i < 20; i++) {
pending += 10;
Isolate.spawn(child, port.sendPort);
}
}
-4
View File
@@ -3617,9 +3617,6 @@ void Isolate::PauseEventHandler() {
#endif // !defined(PRODUCT)
void Isolate::VisitIsolates(IsolateVisitor* visitor) {
if (visitor == nullptr) {
return;
}
IsolateGroup::ForEach([&](IsolateGroup* group) {
group->ForEachIsolate(
[&](Isolate* isolate) { visitor->VisitIsolate(isolate); });
@@ -3635,7 +3632,6 @@ intptr_t Isolate::IsolateListLength() {
}
std::unique_ptr<char[]> Isolate::LookupIsolateNameByPort(Dart_Port port) {
MonitorLocker ml(isolate_creation_monitor_);
std::unique_ptr<char[]> result;
IsolateGroup::ForEach([&](IsolateGroup* group) {
group->ForEachIsolate([&](Isolate* isolate) {