[#46105] [ruby-trunk - Feature #6687][Open] Enumerable#with — "merborne (kyo endo)" <redmine@...>

14 messages 2012/07/02

[#46133] [ruby-trunk - Feature #6688][Open] Object#replace — "prijutme4ty (Ilya Vorontsov)" <prijutme4ty@...>

24 messages 2012/07/03

[#46160] [ruby-trunk - Feature #6693][Open] Don't warn for unused variables starting with _ — "marcandre (Marc-Andre Lafortune)" <ruby-core@...>

15 messages 2012/07/04

[#46200] [ruby-trunk - Bug #6702][Open] Date should be either required or not — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

14 messages 2012/07/05

[#46296] [ruby-trunk - Feature #6717][Open] Method like #instance_eval that returns self (like #tap) — "alexeymuranov (Alexey Muranov)" <redmine@...>

10 messages 2012/07/10

[#46320] [ruby-trunk - Feature #6721][Open] Object#yield_self — "alexeymuranov (Alexey Muranov)" <redmine@...>

25 messages 2012/07/11

[#46339] [ruby-trunk - Bug #6724][Open] waaaaaaant! ( — "zenspider (Ryan Davis)" <redmine@...>

11 messages 2012/07/11

[#46377] [ruby-trunk - Feature #6727][Open] Add Array#rest (with implementation) — "duckinator (Nick Markwell)" <nick@...>

25 messages 2012/07/13

[#46492] [ruby-trunk - Feature #6737][Open] Add Hash#read and alias as #[]. — "trans (Thomas Sawyer)" <transfire@...>

12 messages 2012/07/15

[#46500] [ruby-trunk - Feature #6739][Open] One-line rescue statement should support specifying an exception class — Quintus (Marvin Gülker) <sutniuq@...>

22 messages 2012/07/15

[#46562] [ruby-trunk - Feature #6758][Open] Object#sequence — "merborne (kyo endo)" <redmine@...>

19 messages 2012/07/20

[#46574] [ruby-trunk - Feature #6762][Open] Control interrupt timing — "ko1 (Koichi Sasada)" <redmine@...>

39 messages 2012/07/20

[#46641] [ruby-trunk - Bug #6780][Open] cannot compile zlib module, when cross-compiling. — "jinleileiking (lei king)" <jinleileiking@...>

14 messages 2012/07/23

[#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)" <garysweaver@...>

8 messages 2012/07/23

[#46792] [ruby-trunk - Bug #6799][Open] Digest::*.hexdigest returns an ASCII-8BIT String — "Eregon (Benoit Daloze)" <redmine@...>

11 messages 2012/07/26

[#46799] [ruby-trunk - Feature #6801][Open] String#~ for a here document — "merborne (kyo endo)" <redmine@...>

12 messages 2012/07/27

[#46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name — "alexeymuranov (Alexey Muranov)" <redmine@...>

7 messages 2012/07/28

[#46832] [ruby-trunk - Bug #6807][Open] Can't compile ruby without ruby — "devcurmudgeon (Paul Sherwood)" <storitel@...>

13 messages 2012/07/28

[#46834] [ruby-trunk - Feature #6808][Open] Implicit index for enumerations — "trans (Thomas Sawyer)" <transfire@...>

15 messages 2012/07/28

[#46838] [ruby-trunk - Bug #6810][Open] `module A::B; end` is not equivalent to `module A; module B; end; end` with respect to constant lookup (scope) — "alexeymuranov (Alexey Muranov)" <redmine@...>

17 messages 2012/07/28

[#46896] (Half-baked DRAFT) new `require' framework — SASADA Koichi <ko1@...>

Hi,

22 messages 2012/07/31

[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.

From: "garysweaver (Gary Weaver)" <garysweaver@...>
Date: 2012-07-23 19:27:52 UTC
List: ruby-core #46683
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/

In This Thread