Skip to content

Commit b17b263

Browse files
committed
Ignore debugger threads
MSP-11147 When using the debugger, it adds a thread that should be allowed and not go towards the count.
1 parent 535f69b commit b17b263

File tree

1 file changed

+11
-2
lines changed
  • lib/metasploit/framework/spec/threads

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def self.configure!
3131
unless @configured
3232
RSpec.configure do |config|
3333
config.before(:suite) do
34-
thread_count = Thread.list.count
34+
thread_count = Metasploit::Framework::Spec::Threads::Suite.non_debugger_thread_list.count
3535

3636
# check with if first so that error message can be constructed lazily
3737
if thread_count > EXPECTED_THREAD_COUNT_AROUND_SUITE
@@ -68,7 +68,7 @@ def self.configure!
6868
f.puts 'after(:suite)'
6969
end
7070

71-
thread_list = Thread.list
71+
thread_list = Metasploit::Framework::Spec::Threads::Suite.non_debugger_thread_list
7272

7373
thread_uuids = thread_list.map { |thread|
7474
thread[Metasploit::Framework::Spec::Threads::Suite::UUID_THREAD_LOCAL_VARIABLE]
@@ -195,6 +195,15 @@ def self.caller_by_thread_uuid
195195

196196
lines_by_thread_uuid
197197
end
198+
199+
# @return
200+
def self.non_debugger_thread_list
201+
Thread.list.reject { |thread|
202+
# don't do `is_a? Debugger::DebugThread` because it requires Debugger::DebugThread to be loaded, which it
203+
# won't when not debugging.
204+
thread.class.name == 'Debugger::DebugThread'
205+
}
206+
end
198207
end
199208
end
200209
end

0 commit comments

Comments
 (0)