Project

General

Profile

Actions

Feature #6783

open

Infinite loop in inspect, not overriding inspect, to_s, and no known circular references. Stepping into inspect in debugger locks it up with 100% CPU.

Added by garysweaver (Gary Weaver) over 12 years ago. Updated over 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:46659]

Description

In Ruby 1.9.3p194 in Rails 3.2.6 in rails console, in my script I'm calling inspect on a Ruby object and even though I'm not overriding inspect, to_s, and there are no known circular references, inspect is going into an infinite loop locking Ruby up with 100% CPU usage.

At first, I would think this problem is probably outside of Ruby and either in my code or in a gem that I'm using, however the problem is that using the Debugger gem, if I set a breakpoint above the issue and use "s" (by itself) to step into the line where it calls inspect, it locks up there, so I can't debug the issue. When I do that I hit ctrl-c, I'm in .../.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:

   64      trap("SIGINT") do
=> 65        irb.signal_handle
   66      end

and breaking out of that, or if I don't step into it and I break out of it, I see:

path_to_script/script_name.rb:739:in `call'
path_to_script/script_name.rb:739:in `inspect'
path_to_script/script_name.rb:739:in `inspect'
...
    (~100 times)
    path_to_script/script_name.rb:739:in `block (2 levels) in my_method_name'

In a situation like this, how can I debug the issue? Is there anything in the inspect method that could causing this behavior?

I think the most likely culprit is some bad code on my part in the script, but unfortunately I can't debug it when the debugger can't step into inspect.

Thanks for any help you can provide.


Related issues 3 (1 open2 closed)

Related to Ruby master - Feature #6733: New inspect frameworkOpenActions
Related to Ruby master - Feature #18285: NoMethodError#message uses a lot of CPU/is really expensive to callClosedActions
Is duplicate of Ruby master - Bug #6291: Backtrace printout halts for an extremely long time when large amounts of data are allocatedClosedmatz (Yukihiro Matsumoto)04/14/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0