ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:46659] [ruby-trunk - Bug #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.
@ 2012-07-23 14:22 garysweaver (Gary Weaver)
  2012-07-23 14:29 ` [ruby-core:46662] [ruby-trunk - Bug #6783] " garysweaver (Gary Weaver)
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: garysweaver (Gary Weaver) @ 2012-07-23 14:22 UTC (permalink / raw
  To: ruby-core


Issue #6783 has been reported by garysweaver (Gary Weaver).

----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783

Author: garysweaver (Gary Weaver)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]


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.


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:46662] [ruby-trunk - Bug #6783] 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.
  2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
@ 2012-07-23 14:29 ` garysweaver (Gary Weaver)
  2012-07-23 19:27 ` [ruby-core:46683] " garysweaver (Gary Weaver)
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: garysweaver (Gary Weaver) @ 2012-07-23 14:29 UTC (permalink / raw
  To: ruby-core


Issue #6783 has been updated by garysweaver (Gary Weaver).


Note: unfortunately this is an internal script that depends on a local DB so can't share, but can duplicate bug each time.
----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783#change-28327

Author: garysweaver (Gary Weaver)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]


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.


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:46683] [ruby-trunk - Bug #6783] 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.
  2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
  2012-07-23 14:29 ` [ruby-core:46662] [ruby-trunk - Bug #6783] " garysweaver (Gary Weaver)
@ 2012-07-23 19:27 ` garysweaver (Gary Weaver)
  2012-11-03  3:06 ` [ruby-core:48783] [ruby-trunk - Bug #6783][Closed] " mame (Yusuke Endoh)
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: garysweaver (Gary Weaver) @ 2012-07-23 19:27 UTC (permalink / raw
  To: ruby-core


Issue #6783 has been updated by garysweaver (Gary Weaver).


It was just a circular reference.

Ruby does some level of self-reference checking in inspect, but this doesn't help as much when the association level is a bit deeper. Maybe I would have left my script for a long time, it would have eventually completed.

Here is an example of something with somewhat similar behavior to what I was describing. You can see the breakpoint/stepping in is of little use in such cases. It would be nice if inspect would stop at some point sooner in these cases, but it is good to know it really isn't an infinite loop, just a really long process. Also it really wasn't taking 100% CPU; the process in Activity Monitor in OS X appeared as though it was taking 100%, but I could also see in Activity Monitor that only 12-15% was actually being used.

To reproduce similar behavior:

    class Thing
      attr_accessor :a_hash
      attr_accessor :an_array
      attr_accessor :another_array
    end

    class Reporter
      def report
        first_ref = Thing.new
        this_ref = first_ref
        20.times do
          next_ref = Thing.new
          this_ref.a_hash = {"a#{rand(9999999)} ".to_sym => next_ref}
          this_ref.an_array = [next_ref]
          this_ref.another_array = [next_ref]
          this_ref = next_ref
        end
        this_ref.a_hash = {"a#{rand(9999999)} ".to_sym => first_ref}
        this_ref.an_array = [first_ref]
        this_ref.another_array = [first_ref]
        
        # Uncomment next line if using debugger gem and want to see what I mean about getting stuck when you step into it with 's'
        # breakpoint
        puts first_ref.inspect
      end
    end

    r = Reporter.new
    r.report

----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783#change-28348

Author: garysweaver (Gary Weaver)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]


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.


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:48783] [ruby-trunk - Bug #6783][Closed] 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.
  2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
  2012-07-23 14:29 ` [ruby-core:46662] [ruby-trunk - Bug #6783] " garysweaver (Gary Weaver)
  2012-07-23 19:27 ` [ruby-core:46683] " garysweaver (Gary Weaver)
@ 2012-11-03  3:06 ` mame (Yusuke Endoh)
  2016-08-17 13:15 ` [ruby-core:76948] [Ruby trunk Bug#6783] " stefan.kroes
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mame (Yusuke Endoh) @ 2012-11-03  3:06 UTC (permalink / raw
  To: ruby-core


Issue #6783 has been updated by mame (Yusuke Endoh).

Status changed from Open to Closed


----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783#change-32272

Author: garysweaver (Gary Weaver)
Status: Closed
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]


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.


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:76948] [Ruby trunk Bug#6783] 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.
  2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
                   ` (2 preceding siblings ...)
  2012-11-03  3:06 ` [ruby-core:48783] [ruby-trunk - Bug #6783][Closed] " mame (Yusuke Endoh)
@ 2016-08-17 13:15 ` stefan.kroes
  2016-09-26 11:07 ` [ruby-core:77403] [Ruby trunk Bug#6783][Open] " shyouhei
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: stefan.kroes @ 2016-08-17 13:15 UTC (permalink / raw
  To: ruby-core

Issue #6783 has been updated by Stefan Kroes.


I would like to reopen discussion on this subject. I think the default implementation of #inspect tends to hang/explode for complex/large object graphs with lots of cycles. In 10 years of programming Ruby I ran into this twice and had to waste several hours before finding the problem twice (today and several years ago if I remember correctly). Inspect is often used for generating error messages which will hang in turn, misdirecting debugging efforts to the original error.

To clarify: I don't really think this is a bug, just an aspect of Ruby that may cause grief (especially to new users) and can be improved.

A simple script to reproduce:

```
class Base
  attr_accessor :foos, :bars, :bazs
end

class Foo < Base; end
class Bar < Base; end
class Baz < Base; end

foos = Array.new(100) { Foo.new }
bars = Array.new(100) { Bar.new }
bazs = Array.new(100) { Baz.new }

[*foos, *bars, *bazs].each do |base|
  base.foos = foos
  base.bars = bars
  base.bazs = bazs
end

puts foos.inspect.size
```

```
{14:54}[2.3.1]~ ➭ time ruby test.rb
127165300
ruby test.rb  7.77s user 0.29s system 97% cpu 8.237 total
```

This example seems somewhat contrived and 7 seconds doesn't seem long but I just had a real-life object graph of a large state machine hang my process for at least 20 minutes (broke it off).

I know the documentation for Object#inspect says `User defined classes should override this method to make better representation of obj.` but I don't think many people do this, especially as the default implementation is very useful.

Possible solutions include:

* Further limiting recursion of default inspect
* Limiting number of elements shown in inspect for Hash, Array, etc.
* Putting a timeout on the default inspect, informing the user he/she should override inspect with something sensible for a certain class
  * Timeout should be nested so it triggers for the deepest inspect that takes too long

----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783#change-60177

* Author: Gary Weaver
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:77403] [Ruby trunk Bug#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.
  2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
                   ` (3 preceding siblings ...)
  2016-08-17 13:15 ` [ruby-core:76948] [Ruby trunk Bug#6783] " stefan.kroes
@ 2016-09-26 11:07 ` shyouhei
  2016-09-26 15:02 ` [ruby-core:77410] [Ruby trunk Bug#6783] " headius
  2016-10-11 10:58 ` [ruby-core:77572] " shyouhei
  6 siblings, 0 replies; 8+ messages in thread
From: shyouhei @ 2016-09-26 11:07 UTC (permalink / raw
  To: ruby-core

Issue #6783 has been updated by Shyouhei Urabe.

Status changed from Closed to Open

reopen as per request (seems like it is no longer a bug ticket but a feature request?)

----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783#change-60658

* Author: Gary Weaver
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:77410] [Ruby trunk Bug#6783] 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.
  2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
                   ` (4 preceding siblings ...)
  2016-09-26 11:07 ` [ruby-core:77403] [Ruby trunk Bug#6783][Open] " shyouhei
@ 2016-09-26 15:02 ` headius
  2016-10-11 10:58 ` [ruby-core:77572] " shyouhei
  6 siblings, 0 replies; 8+ messages in thread
From: headius @ 2016-09-26 15:02 UTC (permalink / raw
  To: ruby-core

Issue #6783 has been updated by Charles Nutter.


See also #9725, my issue/request relating to NameError's behavior of carrying the target object and causing huge inspect-driven memory bloat when attempting to print the message.

----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783#change-60666

* Author: Gary Weaver
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:77572] [Ruby trunk Bug#6783] 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.
  2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
                   ` (5 preceding siblings ...)
  2016-09-26 15:02 ` [ruby-core:77410] [Ruby trunk Bug#6783] " headius
@ 2016-10-11 10:58 ` shyouhei
  6 siblings, 0 replies; 8+ messages in thread
From: shyouhei @ 2016-10-11 10:58 UTC (permalink / raw
  To: ruby-core

Issue #6783 has been updated by Shyouhei Urabe.


We looked at this ticket at developer meeting today and found several former tickets that was linked then.  FYI #6733 is the most big-pictured feature request that ultimately solves this problem.  Not yet implemented though.

----------------------------------------
Bug #6783: 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.
https://bugs.ruby-lang.org/issues/6783#change-60843

* Author: Gary Weaver
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-10-11 10:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-23 14:22 [ruby-core:46659] [ruby-trunk - Bug #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 garysweaver (Gary Weaver)
2012-07-23 14:29 ` [ruby-core:46662] [ruby-trunk - Bug #6783] " garysweaver (Gary Weaver)
2012-07-23 19:27 ` [ruby-core:46683] " garysweaver (Gary Weaver)
2012-11-03  3:06 ` [ruby-core:48783] [ruby-trunk - Bug #6783][Closed] " mame (Yusuke Endoh)
2016-08-17 13:15 ` [ruby-core:76948] [Ruby trunk Bug#6783] " stefan.kroes
2016-09-26 11:07 ` [ruby-core:77403] [Ruby trunk Bug#6783][Open] " shyouhei
2016-09-26 15:02 ` [ruby-core:77410] [Ruby trunk Bug#6783] " headius
2016-10-11 10:58 ` [ruby-core:77572] " shyouhei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).