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)
commit08765fac3f4523883ce44ac938fa0523cfb8bbd6
treef9accade74e0082a94c4a96d92631e5239ffaf4e
parent88862eaefafb00a666a519f08df8cef6f7557b25
I finally found the strong reference that was keeping all lldb_private::Process instances from ever destroying themselves: ProcessModID.m_mod_id was holding onto the last stop event with ProcessModID::SetStopEventForLastNaturalStopID(EventSP). This is a bad idea because ProcessEventData contains a strong refereence to the process. This is now fixed by calling ProcessModID::SetStopEventForLastNaturalStopID(EventSP()) to clear this event in Process::SetExitStatus() and in Process::Finalize().

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