[Lldb-commits] [lldb] r366703 - [Windows] Fix race condition between state changes
Adrian McCarthy via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 22 10:03:20 PDT 2019
Author: amccarth
Date: Mon Jul 22 10:03:20 2019
New Revision: 366703
URL: http://llvm.org/viewvc/llvm-project?rev=366703&view=rev
Log:
[Windows] Fix race condition between state changes
Patch by Martin Andersson (martin.andersson at evoma.se)
If the process is resumed before the state is changed to "running"
there is a possibility (when single stepping) that the debugger stops
and changes the state to "stopped" before it is first changed to
"running". This causes the process to ignore the stop event (since
the state did not change) which in turn leads the DebuggerThread to
wait indefinitely for the exception predicate in HandleExceptionEvent.
Differential Revision: https://reviews.llvm.org/D62183
Modified:
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp?rev=366703&r1=366702&r2=366703&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp Mon Jul 22 10:03:20 2019
@@ -205,16 +205,6 @@ Status ProcessWindows::DoResume() {
m_session_data->m_debugger->GetProcess().GetProcessId(),
GetPrivateState());
- ExceptionRecordSP active_exception =
- m_session_data->m_debugger->GetActiveException().lock();
- if (active_exception) {
- // Resume the process and continue processing debug events. Mask the
- // exception so that from the process's view, there is no indication that
- // anything happened.
- m_session_data->m_debugger->ContinueAsyncException(
- ExceptionResult::MaskException);
- }
-
LLDB_LOG(log, "resuming {0} threads.", m_thread_list.GetSize());
bool failed = false;
@@ -233,10 +223,19 @@ Status ProcessWindows::DoResume() {
if (failed) {
error.SetErrorString("ProcessWindows::DoResume failed");
- return error;
} else {
SetPrivateState(eStateRunning);
}
+
+ ExceptionRecordSP active_exception =
+ m_session_data->m_debugger->GetActiveException().lock();
+ if (active_exception) {
+ // Resume the process and continue processing debug events. Mask the
+ // exception so that from the process's view, there is no indication that
+ // anything happened.
+ m_session_data->m_debugger->ContinueAsyncException(
+ ExceptionResult::MaskException);
+ }
} else {
LLDB_LOG(log, "error: process {0} is in state {1}. Returning...",
m_session_data->m_debugger->GetProcess().GetProcessId(),
More information about the lldb-commits
mailing list