<rdar://problem/12500785>
I tracked down a leak that could happen when detaching from a process where the lldb_private::Process objects would stay around forever. This was caused by a eStateDetached event that was queued up on the lldb_private::Process private state thread listener. Since process events contain shared pointers to the process, this is dangerous if they don't get consume or cleared as having the lldb_private::Process class contain a collection of things that have a shared pointer to yourself is obviously bad.
To fix this I modified the Process::Finalize() function to clear this list. The actual thing that was holding onto the ModuleSP and thus the static archive, was a stack frame. Since the process wasn't going away, it still had thread objects and they still had frames. I modified the Thread::Destroy() to clear the stack frames to ensure this further doesn't happen.
llvm-svn: 166964
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 39157dd..a7f3864 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -279,11 +279,16 @@
void
Thread::DestroyThread ()
{
+ m_destroy_called = true;
m_plan_stack.clear();
m_discarded_plan_stack.clear();
m_completed_plan_stack.clear();
m_actual_stop_info_sp.reset();
- m_destroy_called = true;
+ m_reg_context_sp.reset();
+ m_unwinder_ap.reset();
+ Mutex::Locker locker(m_frame_mutex);
+ m_curr_frames_sp.reset();
+ m_prev_frames_sp.reset();
}
void