Skip to content

Commit 33b4238

Browse files
committed
Merge branch 'feature/MSP-11147/thread-leak-detection' into feature/MSP-11605/lazy-thread-creation
MSP-11605
2 parents 024b449 + e3869ee commit 33b4238

File tree

1 file changed

+10
-7
lines changed
  • lib/metasploit/framework/spec/threads

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ def self.configure!
6969
end
7070

7171
thread_list = Metasploit::Framework::Spec::Threads::Suite.non_debugger_thread_list
72-
73-
thread_uuids = thread_list.map { |thread|
74-
thread[Metasploit::Framework::Spec::Threads::Suite::UUID_THREAD_LOCAL_VARIABLE]
75-
}.compact
76-
7772
thread_count = thread_list.count
7873

7974
if thread_count > EXPECTED_THREAD_COUNT_AROUND_SUITE
@@ -82,10 +77,18 @@ def self.configure!
8277
if LOG_PATHNAME.exist?
8378
caller_by_thread_uuid = Metasploit::Framework::Spec::Threads::Suite.caller_by_thread_uuid
8479

85-
thread_uuids.each do |thread_uuid|
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
87+
8688
caller = caller_by_thread_uuid[thread_uuid]
8789

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

9093
error_lines.concat(caller)
9194
end

0 commit comments

Comments
 (0)