diff options
author | Greg Clayton <gclayton@apple.com> | 2015-11-03 22:42:04 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-11-03 22:42:04 +0000 |
commit | fc1e77a9865f43ad7c27bf4eea0e44d20a215e03 (patch) | |
tree | 75a37264e9c5cd4c615d0417a9445f1fb891c405 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | cd9488d521d281c77a16cb2cc61609acca718a2d (diff) | |
download | bcm5719-llvm-fc1e77a9865f43ad7c27bf4eea0e44d20a215e03.tar.gz bcm5719-llvm-fc1e77a9865f43ad7c27bf4eea0e44d20a215e03.zip |
Fix a deadlock when connecting to a remote GDB server that might not support all packets that lldb-server or debugserver supports. The issue was the m_last_stop_packet_mutex mutex was being held by another thread and it was deadlocking getting the thread list. We now try to lock the m_last_stop_packet_mutex, and only continue if we successfully lock it. Else we fall back to qfThreadInfo/qsThreadInfo.
<rdar://problem/22140023>
llvm-svn: 252005
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 8ed7e45f1a2..a6e15d21063 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1832,25 +1832,29 @@ ProcessGDBRemote::UpdateThreadIDList () // that might contain a "threads" key/value pair // Lock the thread stack while we access it - Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex); - // Get the number of stop packets on the stack - int nItems = m_stop_packet_stack.size(); - // Iterate over them - for (int i = 0; i < nItems; i++) + //Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex); + Mutex::Locker stop_stack_lock; + if (stop_stack_lock.TryLock(m_last_stop_packet_mutex)) { - // Get the thread stop info - StringExtractorGDBRemote &stop_info = m_stop_packet_stack[i]; - const std::string &stop_info_str = stop_info.GetStringRef(); - const size_t threads_pos = stop_info_str.find(";threads:"); - if (threads_pos != std::string::npos) + // Get the number of stop packets on the stack + int nItems = m_stop_packet_stack.size(); + // Iterate over them + for (int i = 0; i < nItems; i++) { - const size_t start = threads_pos + strlen(";threads:"); - const size_t end = stop_info_str.find(';', start); - if (end != std::string::npos) + // Get the thread stop info + StringExtractorGDBRemote &stop_info = m_stop_packet_stack[i]; + const std::string &stop_info_str = stop_info.GetStringRef(); + const size_t threads_pos = stop_info_str.find(";threads:"); + if (threads_pos != std::string::npos) { - std::string value = stop_info_str.substr(start, end - start); - if (UpdateThreadIDsFromStopReplyThreadsValue(value)) - return true; + const size_t start = threads_pos + strlen(";threads:"); + const size_t end = stop_info_str.find(';', start); + if (end != std::string::npos) + { + std::string value = stop_info_str.substr(start, end - start); + if (UpdateThreadIDsFromStopReplyThreadsValue(value)) + return true; + } } } } |