Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free terminated ThreadClients #918

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def initialize
@obj_map = {} # { object_id => ... } for CDP

@tp_thread_begin = nil
@tp_thread_end = nil

@commands = {}
@unsafe_context = false

Expand Down Expand Up @@ -169,8 +171,9 @@ def activate ui = nil, on_fork: false
@ui = ui if ui

@tp_thread_begin&.disable
@tp_thread_end&.disable
@tp_thread_begin = nil

@tp_thread_end = nil
@ui.activate self, on_fork: on_fork

q = Queue.new
Expand All @@ -192,6 +195,11 @@ def activate ui = nil, on_fork: false
end
@tp_thread_begin.enable

@tp_thread_end = TracePoint.new(:thread_end) do |tp|
@th_clients.delete(Thread.current)
end
@tp_thread_end.enable

# session start
q << true
session_server_main
Expand All @@ -205,6 +213,7 @@ def deactivate
@thread_stopper.disable
@tp_load_script.disable
@tp_thread_begin.disable
@tp_thread_end.disable
@bps.each_value{|bp| bp.disable}
@th_clients.each_value{|thc| thc.close}
@tracers.values.each{|t| t.disable}
Expand All @@ -219,11 +228,13 @@ def reset_ui ui

# activate new ui
@tp_thread_begin.disable
@tp_thread_end.disable
@ui.activate self
if @ui.respond_to?(:reader_thread) && thc = get_thread_client(@ui.reader_thread)
thc.mark_as_management
end
@tp_thread_begin.enable
@tp_thread_end.enable
end

def pop_event
Expand Down