Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: runtime/vm/debugger_api_impl_test.cc

Issue 2671133002: Fix for issue 28606 - Wait for thread that runs the interrupted isolate to exit completely before e… (Closed)
Patch Set: Address code review comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger_api_impl_test.cc
diff --git a/runtime/vm/debugger_api_impl_test.cc b/runtime/vm/debugger_api_impl_test.cc
index beb26e467b270b470d7b8116732727c5de4ef278..ee47df91c54befe28139ed51089bfc845238bc61 100644
--- a/runtime/vm/debugger_api_impl_test.cc
+++ b/runtime/vm/debugger_api_impl_test.cc
@@ -1446,6 +1446,7 @@ VM_UNIT_TEST_CASE(Debug_IsolateID) {
static Monitor* sync = NULL;
static bool isolate_interrupted = false;
static bool pause_event_handled = false;
+static bool interrupt_thread_stopped = false;
static Dart_IsolateId interrupt_isolate_id = ILLEGAL_ISOLATE_ID;
static volatile bool continue_isolate_loop = true;
@@ -1533,6 +1534,12 @@ static void InterruptIsolateRun(uword unused) {
EXPECT_VALID(retval);
Dart_ExitScope();
Dart_ShutdownIsolate();
+ {
+ // Notify the waiting thread that we are done.
+ MonitorLocker ml(sync);
+ interrupt_thread_stopped = true;
+ ml.Notify();
+ }
}
@@ -1543,6 +1550,10 @@ TEST_CASE(Debug_InterruptIsolate) {
Dart_SetIsolateEventHandler(&TestInterruptIsolate);
EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
Dart_SetPausedEventHandler(InterruptIsolateHandler);
+ {
+ MonitorLocker ml(sync);
+ interrupt_thread_stopped = false;
+ }
int result = OSThread::Start("DebugInterruptIsolate", InterruptIsolateRun, 0);
EXPECT_EQ(0, result);
@@ -1580,6 +1591,17 @@ TEST_CASE(Debug_InterruptIsolate) {
}
}
EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
+
+ // Wait for the OSThread that we started above, if we do
+ // not wait we end up with a race between the process
+ // exiting and cleaning up while the thread above is cleaning
+ // up stuff from the isolate leading to flaky crashes.
+ {
+ MonitorLocker ml(sync);
+ while (!interrupt_thread_stopped) {
+ ml.Wait();
+ }
+ }
OS::PrintErr("Complete\n");
FLAG_trace_shutdown = saved_flag;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698