Your environment
ruby -v: 3.1.3
rdbg -v: 1.7.1
Describe the bug
When the following conditions all match, the debugger has a high possibility to freeze:
-
Inside a Rails app with Puma web server
-
The breakpoint is inside a timeout call, like
def hello
Timeout.timeout(3600) do
binding.b
end
end
-
From the breakpoint, executes something that calls Timeout.timeout underneath
To Reproduce
I've documented reproduction steps in this repo.
Expected behavior
The debugger doesn't freeze.
Additional context
It may not be the root cause, but Timeout's thread being stopped by the debugger plays a major role here.
If we somehow modify this method to skip pausing the Timeout thread, like
private def thread_stopper
TracePoint.new(:line) do
# run on each thread
tc = ThreadClient.current
next if tc.management?
next unless tc.running?
next if tc == @tc
next if tc.thread.name && tc.thread.name.match?(/Timeout/)
tc.on_pause
end
end
Then the issue doesn't occur.