diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 3a101d6ee..99c78af1d 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1678,6 +1678,14 @@ def get_thread_client th = Thread.current private def thread_stopper TracePoint.new(:line) do + # When leave_subsession pops the subsession stack and sets @tc = nil, + # there is a window before the TracePoint is disabled where this block + # can still fire on other threads. Without this guard, the main thread + # (back in IRB's eval loop) would be paused by on_pause, but the + # session server is already waiting on @q_evt.pop -- causing a mutual + # deadlock ("No live threads left. Deadlock?"). + next unless in_subsession? + # run on each thread tc = ThreadClient.current next if tc.management?