I finally found the strong reference that was keeping all lldb_private::Process insta...
authorGreg Clayton <gclayton@apple.com>
Thu, 28 May 2015 03:24:30 +0000 (03:24 +0000)
committerGreg Clayton <gclayton@apple.com>
Thu, 28 May 2015 03:24:30 +0000 (03:24 +0000)
This was the original cause of the file descriptor leaks that would cause the test suite to die after running a few hundred processes since no process would ever get destroyed and the communication channel in ProcessGDBRemote and the ProcessIOHandler would never close their pipes.

This process leak was previously worked around by closing the pipes when the communication channel was disconnected.

This was found by using "ptr_refs" from the heap.py in the lldb.macosx.heap module. It was able to find all strong references to the Process and helped me to figure out who was holding this extra reference.

llvm-svn: 238392

lldb/source/Target/Process.cpp

index f0bd9e3..3380d0e 100644 (file)
@@ -874,6 +874,9 @@ Process::Finalize()
     m_instrumentation_runtimes.clear();
     m_next_event_action_ap.reset();
     m_stop_info_override_callback = NULL;
+    // Clear the last natural stop ID since it has a strong
+    // reference to this process
+    m_mod_id.SetStopEventForLastNaturalStopID(EventSP());
 //#ifdef LLDB_CONFIGURATION_DEBUG
 //    StreamFile s(stdout, false);
 //    EventSP event_sp;
@@ -1467,6 +1470,10 @@ Process::SetExitStatus (int status, const char *cstr)
         m_process_input_reader.reset();
     }
 
+    // Clear the last natural stop ID since it has a strong
+    // reference to this process
+    m_mod_id.SetStopEventForLastNaturalStopID(EventSP());
+
     SetPrivateState (eStateExited);
 
     // Allow subclasses to do some cleanup