Repository navigation
Description
Your environment
ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]rdbg -v: rdbg 1.10.0
Describe the bug
I'm trying to debug a separate issue, where it seems the WebConsole thread is hanging instead of reporting an error. When I connect to the puma server with rdbg -A, do th to list the threads, then th 13 (or whatever to pick the stuck thread), then do bt, I get a big exception printed to the puma output:
[
"DEBUGGER Exception: /home/rando/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/thread_client.rb:1252",
#<NoMethodError: undefined method '+' for nil>,
[
"/home/rando/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/thread_client.rb:85:in 'DEBUGGER__::ThreadClient#default_frame_formatter'",
"/home/rando/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/thread_client.rb:755:in 'Method#call'",
"/home/rando/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/thread_client.rb:755:in 'DEBUGGER__::ThreadClient#frame_str'",
"/home/rando/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/thread_client.rb:742:in 'block in DEBUGGER__::ThreadClient#show_frames'",
"<internal:numeric>:257:in 'Integer#times'",
# ...
(formatted for readability, such as it is)
Also, when this happens, the console input for rdbg doesn't return. I have to hit ^C, and it prints "Stop by SIGURG", and I'm able to input commands again.
To Reproduce
- Have a stuck thread using 100% CPU (I'm not sure that that's a requirement, its what I'm investigating).
- Connect rdbg to the process, and switch to the stuck thread.
- Print the backtrace for that thread.
Expected behavior
Successfully print the backtrace for a frame with nil for block_loc, or determine why a frame would have that.
Additional context
It looks like its coming from thread_client.rb:85, so I printed out the values for level, block_loc, args and frame:
{
:level => "",
:block_loc => nil,
:args => [],
:frame => #<Object:ActionDispatch::ServerTiming:0x00045ba0
attr_reader :callee = nil,
attr_reader :local_variables = nil,
binding = #<Binding:0x00007f67cf5e0e78>,
class = ActionDispatch::ServerTiming < Object,
dupped_binding = nil,
frame_depth = 17,
has_raised_exception = nil,
has_return_value = nil,
iseq = <RubyVM::InstructionSequence:block in call@/home/rando/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/actionpack-7.1.5.1/lib/action_dispatch/middleware/server_timing.rb:58>,
location = "/home/rando/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/actionpack-7.1.5.1/lib/action_dispatch/middleware/server_timing.rb:24:in 'ActionDispatch::ServerTiming::Subscriber#collect_events'",
raised_exception = nil,
return_value = nil,
self = #<ActionDispatch::ServerTiming:0x00007f67e8e5f1f8 ...wall of text, looks like a middleware stack...>,
show_line = nil
>
}
I'm able to get it to not blow up by changing the code like this:
- "#{colorize_blue("block")}#{args_str} in #{colorize_blue(block_loc + level)}"
+ "#{colorize_blue('block')}#{args_str} in #{colorize_blue([block_loc, level].compact.join)}"But, I'm not sure why block_loc is nil (and level is empty string), and if that indicates a larger problem.
Activity
cguess commentedon Mar 16, 2025
I'm seeing the same problem on my end.
chaffeqa commentedon Mar 25, 2025
Ditto
andrepiske commentedon Apr 26, 2025
I'm seeing the same. I'm able to reproduce the bug with:
Just run it with ruby 3.4.1 and debug 1.10.0 and the error pops up. The issue doesn't happen with ruby 3.3.8.
It seems that the regexp approach introduced in https://github.com/ruby/debug/pull/91/files#diff-372c5559dee1ab1a9fa1bace23d908bca7e295bfd24f10906a866529a7be6bc7 is not enough to cover all cases.
For the ruby code above, the result of
location.labelin ruby 3.4.1 is the string"Kernel#loop", which doesn't match against theBLOCK_LABL_REGEXPregexp.In ruby 3.3.8,
location.labelreturnsblock in some_methodwhich then matches against that regex.I tested with ruby 3.5.0-preview1 and the string is also
Kernel#loop, so it also fails to match against the regex.ko1 commentedon Jun 4, 2025
#1137
Thank you!!