[Lldb-commits] [PATCH] D14083: Fix race condition in process resume

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 26 10:08:35 PDT 2015


labath created this revision.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.

Gdb-remote's async thread sent out the eBroadcastBitRunPacketSent message *before* actually
sending out the continue packet. Since it's this message the actually triggers the public state
transition, it could happen (and it did happen in TestAttachResume, which does an "process
interrupt" right after a continue) that we attempt to stop the inferior before it was actually
started (which obviously did not end well). This fixes the problem by moving the broadcast after
the packet was actually sent.

http://reviews.llvm.org/D14083

Files:
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  test/functionalities/attach_resume/TestAttachResume.py

Index: test/functionalities/attach_resume/TestAttachResume.py
===================================================================
--- test/functionalities/attach_resume/TestAttachResume.py
+++ test/functionalities/attach_resume/TestAttachResume.py
@@ -20,7 +20,6 @@
     @skipIfRemote
     @expectedFailureFreeBSD('llvm.org/pr19310')
     @expectedFailureWindows("llvm.org/pr24778")
-    @expectedFlakeyLinux('llvm.org/pr19310')
     def test_attach_continue_interrupt_detach(self):
         """Test attach/continue/interrupt/detach"""
         self.build()
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1049,7 +1049,6 @@
     Mutex::Locker locker(m_sequence_mutex);
     StateType state = eStateRunning;
 
-    BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
     m_public_is_running.SetValue (true, eBroadcastNever);
     // Set the starting continue packet into "continue_packet". This packet
     // may change if we are interrupted and we continue after an async packet...
@@ -1059,6 +1058,7 @@
     const auto sigint_signo = process->GetUnixSignals()->GetSignalNumberFromName("SIGINT");
 
     bool got_async_packet = false;
+    bool broadcast_sent = false;
     
     while (state == eStateRunning)
     {
@@ -1071,6 +1071,12 @@
             else
                 m_interrupt_sent = false;
         
+            if (! broadcast_sent)
+            {
+                BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
+                broadcast_sent = true;
+            }
+
             m_private_is_running.SetValue (true, eBroadcastAlways);
         }
         


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14083.38429.patch
Type: text/x-patch
Size: 1816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151026/cde3a0bd/attachment.bin>


More information about the lldb-commits mailing list