Skip to content

Commit 35d98d5

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[vm] Fix a number of vm/cc tests that started crashing after a previous CL
This CL makes the following tests pass in debug mode: - vm/cc/CleanupBequestNeverReceived - vm/cc/CustomIsolates - vm/cc/ManySimpleTasksWithZones - vm/cc/ReceivesSendAndExitMessage TEST=CL only modifies (and fixes) vm/cc tests Closes #44141 Change-Id: Ie09f93e35a0a4001f8a0364fbeddd5b5446445da Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171886 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
1 parent b1b5f82 commit 35d98d5

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

runtime/vm/heap/heap_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ class MergeIsolatesHeapsHandler : public MessageHandler {
583583
};
584584

585585
VM_UNIT_TEST_CASE(CleanupBequestNeverReceived) {
586+
// This test uses features from isolate groups
587+
FLAG_enable_isolate_groups = true;
588+
586589
const char* TEST_MESSAGE = "hello, world";
587590
Dart_Isolate parent = TestCase::CreateTestIsolate("parent");
588591
EXPECT_EQ(parent, Dart_CurrentIsolate());
@@ -615,6 +618,9 @@ VM_UNIT_TEST_CASE(CleanupBequestNeverReceived) {
615618
}
616619

617620
VM_UNIT_TEST_CASE(ReceivesSendAndExitMessage) {
621+
// This test uses features from isolate groups
622+
FLAG_enable_isolate_groups = true;
623+
618624
const char* TEST_MESSAGE = "hello, world";
619625
Dart_Isolate parent = TestCase::CreateTestIsolate("parent");
620626
EXPECT_EQ(parent, Dart_CurrentIsolate());

runtime/vm/heap/verifier.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,22 @@ VerifyCanonicalVisitor::VerifyCanonicalVisitor(Thread* thread)
8989
: thread_(thread), instanceHandle_(Instance::Handle(thread->zone())) {}
9090

9191
void VerifyCanonicalVisitor::VisitObject(ObjectPtr obj) {
92+
// The caller of this function is walking heap pages using the
93+
// ExclusivePageIterator - which holds the pages lock.
94+
//
95+
// If we allow handle verification, then any assignment to a handle will call
96+
// `heap()->Contains()` for heap objects, which in return is implemented by
97+
// walking pages using ExclusivePageIterator, which can cause a deadlock.
98+
//
99+
// Therefore we disable the handle verification here.
100+
const bool old_verify_flag = FLAG_verify_handles;
101+
FLAG_verify_handles = false;
102+
92103
// TODO(dartbug.com/36097): The heap walk can encounter canonical objects of
93104
// other isolates. We should either scan live objects from the roots of each
94105
// individual isolate, or wait until we are ready to share constants across
95106
// isolates.
96-
if (!FLAG_enable_isolate_groups) {
107+
if (!FLAG_enable_isolate_groups || FLAG_precompiled_mode) {
97108
if ((obj->GetClassId() >= kInstanceCid) &&
98109
(obj->GetClassId() != kTypeArgumentsCid)) {
99110
if (obj->ptr()->IsCanonical()) {
@@ -107,6 +118,7 @@ void VerifyCanonicalVisitor::VisitObject(ObjectPtr obj) {
107118
}
108119
}
109120
}
121+
FLAG_verify_handles = old_verify_flag;
110122
}
111123
#endif // defined(DEBUG)
112124

runtime/vm/thread_test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ ISOLATE_UNIT_TEST_CASE(ManySimpleTasksWithZones) {
296296
bool wait = true;
297297

298298
EXPECT(isolate->heap()->GrowthControlState());
299-
isolate->heap()->DisableGrowthControl();
299+
300+
NoHeapGrowthControlScope no_heap_growth_scope;
301+
300302
for (intptr_t i = 0; i < kTaskCount; i++) {
301303
Dart::thread_pool()->Run<SimpleTaskWithZoneAllocation>(
302304
(i + 1), isolate, &threads[i], &sync, &monitor, &done_count, &wait);

0 commit comments

Comments
 (0)