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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_mirrors_api.h" 5 #include "include/dart_mirrors_api.h"
6 #include "include/dart_tools_api.h" 6 #include "include/dart_tools_api.h"
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 Dart_ExitScope(); 1439 Dart_ExitScope();
1440 Dart_ShutdownIsolate(); 1440 Dart_ShutdownIsolate();
1441 Dart_SetIsolateEventHandler(NULL); 1441 Dart_SetIsolateEventHandler(NULL);
1442 EXPECT(verify_callback == 0x5); // Only created and shutdown events. 1442 EXPECT(verify_callback == 0x5); // Only created and shutdown events.
1443 } 1443 }
1444 1444
1445 1445
1446 static Monitor* sync = NULL; 1446 static Monitor* sync = NULL;
1447 static bool isolate_interrupted = false; 1447 static bool isolate_interrupted = false;
1448 static bool pause_event_handled = false; 1448 static bool pause_event_handled = false;
1449 static bool interrupt_thread_stopped = false;
1449 static Dart_IsolateId interrupt_isolate_id = ILLEGAL_ISOLATE_ID; 1450 static Dart_IsolateId interrupt_isolate_id = ILLEGAL_ISOLATE_ID;
1450 static volatile bool continue_isolate_loop = true; 1451 static volatile bool continue_isolate_loop = true;
1451 1452
1452 1453
1453 static void InterruptIsolateHandler(Dart_IsolateId isolateId, 1454 static void InterruptIsolateHandler(Dart_IsolateId isolateId,
1454 intptr_t breakpointId, 1455 intptr_t breakpointId,
1455 const Dart_CodeLocation& location) { 1456 const Dart_CodeLocation& location) {
1456 MonitorLocker ml(sync); 1457 MonitorLocker ml(sync);
1457 pause_event_handled = true; 1458 pause_event_handled = true;
1458 ml.Notify(); 1459 ml.Notify();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 LoadScript(kScriptChars); 1527 LoadScript(kScriptChars);
1527 1528
1528 Dart_Handle result = 1529 Dart_Handle result =
1529 Dart_SetNativeResolver(script_lib, &InterruptNativeResolver, NULL); 1530 Dart_SetNativeResolver(script_lib, &InterruptNativeResolver, NULL);
1530 EXPECT_VALID(result); 1531 EXPECT_VALID(result);
1531 1532
1532 Dart_Handle retval = Invoke("main"); 1533 Dart_Handle retval = Invoke("main");
1533 EXPECT_VALID(retval); 1534 EXPECT_VALID(retval);
1534 Dart_ExitScope(); 1535 Dart_ExitScope();
1535 Dart_ShutdownIsolate(); 1536 Dart_ShutdownIsolate();
1537 {
1538 // Notify the waiting thread that we are done.
1539 MonitorLocker ml(sync);
1540 interrupt_thread_stopped = true;
1541 ml.Notify();
1542 }
1536 } 1543 }
1537 1544
1538 1545
1539 TEST_CASE(Debug_InterruptIsolate) { 1546 TEST_CASE(Debug_InterruptIsolate) {
1540 bool saved_flag = FLAG_trace_shutdown; 1547 bool saved_flag = FLAG_trace_shutdown;
1541 FLAG_trace_shutdown = true; 1548 FLAG_trace_shutdown = true;
1542 sync = new Monitor(); 1549 sync = new Monitor();
1543 Dart_SetIsolateEventHandler(&TestInterruptIsolate); 1550 Dart_SetIsolateEventHandler(&TestInterruptIsolate);
1544 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1551 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
1545 Dart_SetPausedEventHandler(InterruptIsolateHandler); 1552 Dart_SetPausedEventHandler(InterruptIsolateHandler);
1553 {
1554 MonitorLocker ml(sync);
1555 interrupt_thread_stopped = false;
1556 }
1546 int result = OSThread::Start("DebugInterruptIsolate", InterruptIsolateRun, 0); 1557 int result = OSThread::Start("DebugInterruptIsolate", InterruptIsolateRun, 0);
1547 EXPECT_EQ(0, result); 1558 EXPECT_EQ(0, result);
1548 1559
1549 // Wait for the test isolate to be created. 1560 // Wait for the test isolate to be created.
1550 { 1561 {
1551 OS::PrintErr("Waiting for isolate to be created\n"); 1562 OS::PrintErr("Waiting for isolate to be created\n");
1552 MonitorLocker ml(sync); 1563 MonitorLocker ml(sync);
1553 while (interrupt_isolate_id == ILLEGAL_ISOLATE_ID) { 1564 while (interrupt_isolate_id == ILLEGAL_ISOLATE_ID) {
1554 ml.Wait(); 1565 ml.Wait();
1555 } 1566 }
(...skipping 17 matching lines...) Expand all
1573 1584
1574 // Wait for the test isolate to shutdown. 1585 // Wait for the test isolate to shutdown.
1575 { 1586 {
1576 OS::PrintErr("Waiting for isolate to be shut down\n"); 1587 OS::PrintErr("Waiting for isolate to be shut down\n");
1577 MonitorLocker ml(sync); 1588 MonitorLocker ml(sync);
1578 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) { 1589 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) {
1579 ml.Wait(); 1590 ml.Wait();
1580 } 1591 }
1581 } 1592 }
1582 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1593 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
1594
1595 // Wait for the OSThread that we started above, if we do
1596 // not wait we end up with a race between the process
1597 // exiting and cleaning up while the thread above is cleaning
1598 // up stuff from the isolate leading to flaky crashes.
1599 {
1600 MonitorLocker ml(sync);
1601 while (!interrupt_thread_stopped) {
1602 ml.Wait();
1603 }
1604 }
1583 OS::PrintErr("Complete\n"); 1605 OS::PrintErr("Complete\n");
1584 FLAG_trace_shutdown = saved_flag; 1606 FLAG_trace_shutdown = saved_flag;
1585 } 1607 }
1586 1608
1587 1609
1588 static void StackTraceDump1BreakpointHandler( 1610 static void StackTraceDump1BreakpointHandler(
1589 Dart_IsolateId isolate_id, 1611 Dart_IsolateId isolate_id,
1590 intptr_t bp_id, 1612 intptr_t bp_id,
1591 const Dart_CodeLocation& location) { 1613 const Dart_CodeLocation& location) {
1592 Dart_StackTrace trace; 1614 Dart_StackTrace trace;
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 " null, 5, 17, 5, 18, 9, 19, 12," 2356 " null, 5, 17, 5, 18, 9, 19, 12,"
2335 " null, 6, 21, 1," 2357 " null, 6, 21, 1,"
2336 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," 2358 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8,"
2337 " null, 9, 29, 1]", 2359 " null, 9, 29, 1]",
2338 tokens_cstr); 2360 tokens_cstr);
2339 } 2361 }
2340 2362
2341 #endif 2363 #endif
2342 2364
2343 } // namespace dart 2365 } // namespace dart
OLDNEW
« 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