From 0fd67b537bdf5afe09dff10ff3fe325c1a949efe Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Thu, 17 May 2018 21:34:24 +0000 Subject: [Windows, Process] Fix an issue in windows thread handling that was causing LLDB to hang Summary: The function ResumeThread on Windows returns a DWORD which is an unsigned int. In TargetThreadWindows::DoResume, there's code that determines how many times to call ResumeThread based on whether the return value is greater than 0. Since the function returns -1 (as an unsigned int) on failure, this was getting stuck in an infinite loop if ResumeThread failed for any reason. The correct thing to do is check whether the return value is -1 and then return the appropriate error instead of ignoring the return value. Reviewers: asmith, zturner, labath Reviewed By: zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D47020 llvm-svn: 332670 --- .../Plugins/Process/Windows/Common/ProcessWindows.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp') diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index ea919d5d98e..13b8a49ca6e 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -349,13 +349,23 @@ Status ProcessWindows::DoResume() { LLDB_LOG(log, "resuming {0} threads.", m_thread_list.GetSize()); + bool failed = false; for (uint32_t i = 0; i < m_thread_list.GetSize(); ++i) { auto thread = std::static_pointer_cast( m_thread_list.GetThreadAtIndex(i)); - thread->DoResume(); + Status result = thread->DoResume(); + if (result.Fail()) { + failed = true; + LLDB_LOG(log, "Trying to resume thread at index {0}, but failed with error {1}.", i, result); + } } - SetPrivateState(eStateRunning); + if (failed) { + error.SetErrorString("ProcessWindows::DoResume failed"); + return error; + } else { + SetPrivateState(eStateRunning); + } } else { LLDB_LOG(log, "error: process %I64u is in state %u. Returning...", m_session_data->m_debugger->GetProcess().GetProcessId(), -- cgit v1.2.3