[Lldb-commits] [lldb] r121647 - /lldb/trunk/source/Core/Communication.cpp

Greg Clayton gclayton at apple.com
Sun Dec 12 13:50:58 PST 2010


Author: gclayton
Date: Sun Dec 12 15:50:57 2010
New Revision: 121647

URL: http://llvm.org/viewvc/llvm-project?rev=121647&view=rev
Log:
Fixed a multi-threaded race condition that could happen when communication classes are shutting down. We currently don't protect communication connection classes against multi-threaded access. The connection is stored in the lldb_private::Communication.m_connection_ap auto_ptr member. We either need to add protections when accessing this class or not let anything racy occur. With this fix, we are doing the latter.

Modified:
    lldb/trunk/source/Core/Communication.cpp

Modified: lldb/trunk/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=121647&r1=121646&r2=121647&view=diff
==============================================================================
--- lldb/trunk/source/Core/Communication.cpp (original)
+++ lldb/trunk/source/Core/Communication.cpp Sun Dec 12 15:50:57 2010
@@ -94,7 +94,16 @@
     if (m_connection_ap.get())
     {
         ConnectionStatus status = m_connection_ap->Disconnect (error_ptr);
-        m_connection_ap.reset();
+        // We currently don't protect m_connection_ap with any mutex for 
+        // multi-threaded environments. So lets not nuke our connection class 
+        // without putting some multi-threaded protections in. We also probably
+        // don't want to pay for the overhead it might cause if every time we
+        // access the connection we have to take a lock.
+        //
+        // This auto_ptr will cleanup after itself when this object goes away,
+        // so there is no need to currently have it destroy itself immediately
+        // upon disconnnect.
+        //m_connection_ap.reset();
         return status;
     }
     return eConnectionStatusNoConnection;
@@ -347,6 +356,7 @@
     // Let clients know that this thread is exiting
     comm->BroadcastEvent (eBroadcastBitReadThreadDidExit);
     comm->m_read_thread = LLDB_INVALID_HOST_THREAD;
+    comm->Disconnect();
     return NULL;
 }
 





More information about the lldb-commits mailing list