| 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;
|
| }
|
|
|