[Lldb-commits] [lldb] fix: Target Process may crash or freezes on detaching process on windows (PR #115712)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 13 07:58:31 PST 2024
================
@@ -169,6 +169,38 @@ Status ProcessWindows::DoDetach(bool keep_stopped) {
Log *log = GetLog(WindowsLog::Process);
StateType private_state = GetPrivateState();
if (private_state != eStateExited && private_state != eStateDetached) {
+ if (!keep_stopped) {
+ // if the thread is suspended by lldb, we have to resume threads before
+ // detaching process. When we do after DetachProcess(), thread handles
+ // become invalid so we do before detach.
+ if (private_state == eStateStopped || private_state == eStateCrashed) {
+ LLDB_LOG(log, "process {0} is in state {1}. Resuming for detach...",
+ m_session_data->m_debugger->GetProcess().GetProcessId(),
+ GetPrivateState());
+
+ LLDB_LOG(log, "resuming {0} threads for detach.",
+ m_thread_list.GetSize());
+
+ bool failed = false;
+ for (uint32_t i = 0; i < m_thread_list.GetSize(); ++i) {
+ auto thread = std::static_pointer_cast<TargetThreadWindows>(
+ m_thread_list.GetThreadAtIndex(i));
+ Status result = thread->DoResume();
----------------
labath wrote:
> No, the process will not suspend.
> The process will receive the exception and the process handles it instead.
Ok, just so we're clear: If the exception happens after the last call to `WaitForDebugEvent` (but before the call to `DebugActiveProcessStop`), the process will *not* stay stopped, but it will receive the exception (and then either handle it or get killed by it). True or false?
https://github.com/llvm/llvm-project/pull/115712
More information about the lldb-commits
mailing list