Include Thread status when printing leaked threads

MSP-11147

Sometime travis-ci is showing leaked threads even when
'Msf::Framework#threads cleaner' is being used, so I'm adding the
`Thread#status` to the data printed about the Thread to see if the
sometimes leaked threads have an odd status.  There's still a chance
that there will be a race-condition between when I call Thread.list and
I ask for each Thread's status that the VM could finish aborting a
Thread so that status I print isn't the same as the one that caused the
Thread to be returned in Thread.list.
bug/bundler_fix
Luke Imhoff 2014-11-17 09:30:46 -06:00
parent ba836f2383
commit e3869ee1ae
No known key found for this signature in database
GPG Key ID: 5B1FB01FB33356F8
1 changed files with 9 additions and 5 deletions

View File

@ -77,14 +77,18 @@ module Metasploit
if LOG_PATHNAME.exist?
caller_by_thread_uuid = Metasploit::Framework::Spec::Threads::Suite.caller_by_thread_uuid
thread_uuids = thread_list.map { |thread|
thread[Metasploit::Framework::Spec::Threads::Suite::UUID_THREAD_LOCAL_VARIABLE]
}.compact
thread_list.each do |thread|
thread_uuid = thread[Metasploit::Framework::Spec::Threads::Suite::UUID_THREAD_LOCAL_VARIABLE]
# unmanaged thread, such as the main VM thread
unless thread_uuid
next
end
thread_uuids.each do |thread_uuid|
caller = caller_by_thread_uuid[thread_uuid]
error_lines << "Thread #{thread_uuid}\n"
error_lines << "Thread #{thread_uuid}'s status is #{thread.status.inspect} " \
"and was started here:\n"
error_lines.concat(caller)
end