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

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 self 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 interrupt_thread_stopped = false;
Florian Schneider 2017/02/06 21:02:28 Could the other thread see an uninitialized value
siva 2017/02/06 21:17:41 The other thread starts after this assignment so s
1546 int result = OSThread::Start("DebugInterruptIsolate", InterruptIsolateRun, 0); 1554 int result = OSThread::Start("DebugInterruptIsolate", InterruptIsolateRun, 0);
1547 EXPECT_EQ(0, result); 1555 EXPECT_EQ(0, result);
1548 1556
1549 // Wait for the test isolate to be created. 1557 // Wait for the test isolate to be created.
1550 { 1558 {
1551 OS::PrintErr("Waiting for isolate to be created\n"); 1559 OS::PrintErr("Waiting for isolate to be created\n");
1552 MonitorLocker ml(sync); 1560 MonitorLocker ml(sync);
1553 while (interrupt_isolate_id == ILLEGAL_ISOLATE_ID) { 1561 while (interrupt_isolate_id == ILLEGAL_ISOLATE_ID) {
1554 ml.Wait(); 1562 ml.Wait();
1555 } 1563 }
(...skipping 16 matching lines...) Expand all
1572 EXPECT(pause_event_handled); 1580 EXPECT(pause_event_handled);
1573 1581
1574 // Wait for the test isolate to shutdown. 1582 // Wait for the test isolate to shutdown.
1575 { 1583 {
1576 OS::PrintErr("Waiting for isolate to be shut down\n"); 1584 OS::PrintErr("Waiting for isolate to be shut down\n");
1577 MonitorLocker ml(sync); 1585 MonitorLocker ml(sync);
1578 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) { 1586 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) {
1579 ml.Wait(); 1587 ml.Wait();
1580 } 1588 }
1581 } 1589 }
1582 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1590 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
hausner 2017/02/04 06:18:37 I guess we could eliminate waiting for the isolate
siva 2017/02/06 20:15:16 The test wants to test the three stages that the h
1591
1592 // Wait for the OSThread that we started above, if we do
1593 // not wait we end up with a race between the process
1594 // exiting and cleaning up while the thread above is cleaning
1595 // up stuff from the isolate leading to flaky crashes.
1596 {
1597 MonitorLocker ml(sync);
1598 while (!interrupt_thread_stopped) {
1599 ml.Wait();
1600 }
1601 }
1583 OS::PrintErr("Complete\n"); 1602 OS::PrintErr("Complete\n");
1584 FLAG_trace_shutdown = saved_flag; 1603 FLAG_trace_shutdown = saved_flag;
1585 } 1604 }
1586 1605
1587 1606
1588 static void StackTraceDump1BreakpointHandler( 1607 static void StackTraceDump1BreakpointHandler(
1589 Dart_IsolateId isolate_id, 1608 Dart_IsolateId isolate_id,
1590 intptr_t bp_id, 1609 intptr_t bp_id,
1591 const Dart_CodeLocation& location) { 1610 const Dart_CodeLocation& location) {
1592 Dart_StackTrace trace; 1611 Dart_StackTrace trace;
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 " null, 5, 17, 5, 18, 9, 19, 12," 2353 " null, 5, 17, 5, 18, 9, 19, 12,"
2335 " null, 6, 21, 1," 2354 " null, 6, 21, 1,"
2336 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," 2355 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8,"
2337 " null, 9, 29, 1]", 2356 " null, 9, 29, 1]",
2338 tokens_cstr); 2357 tokens_cstr);
2339 } 2358 }
2340 2359
2341 #endif 2360 #endif
2342 2361
2343 } // namespace dart 2362 } // 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