Skip to content

Commit e3869ee

Browse files
committed
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.
1 parent ba836f2 commit e3869ee

File tree

1 file changed

+9
-5
lines changed
  • lib/metasploit/framework/spec/threads

1 file changed

+9
-5
lines changed

lib/metasploit/framework/spec/threads/suite.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ def self.configure!
7777
if LOG_PATHNAME.exist?
7878
caller_by_thread_uuid = Metasploit::Framework::Spec::Threads::Suite.caller_by_thread_uuid
7979

80-
thread_uuids = thread_list.map { |thread|
81-
thread[Metasploit::Framework::Spec::Threads::Suite::UUID_THREAD_LOCAL_VARIABLE]
82-
}.compact
80+
thread_list.each do |thread|
81+
thread_uuid = thread[Metasploit::Framework::Spec::Threads::Suite::UUID_THREAD_LOCAL_VARIABLE]
82+
83+
# unmanaged thread, such as the main VM thread
84+
unless thread_uuid
85+
next
86+
end
8387

84-
thread_uuids.each do |thread_uuid|
8588
caller = caller_by_thread_uuid[thread_uuid]
8689

87-
error_lines << "Thread #{thread_uuid}\n"
90+
error_lines << "Thread #{thread_uuid}'s status is #{thread.status.inspect} " \
91+
"and was started here:\n"
8892

8993
error_lines.concat(caller)
9094
end

0 commit comments

Comments
 (0)