Debugger disconnects for no apparent reason

I'm complete novice to Ruby and RubyMine (but not to IntelliJ). I'm just trying "Sudoku" game example from the first chapter of "The Ruby Programming language". It runs just fine, producing correct results. However if I run with debugger without any breakpoints it does not produce expected result (however it exists without errors). If I add any breakpoint as soon as it enters Puzzle class debugger disconnects and output produced is exit code 1. This is with latest RubyMine on Mac 10.6.2 Everything is at default. Help much appreciated.

0
28 comments

Hi, could you please try launch RubyMine with Java property ruby.debug.output=true ?

0

I added -Druby.debug.output=true to REQUIRED_RUBYMINE_JVM_ARGS in file rubymine.bat. Is that the right place? (it's on MAC). It did not make any difference. Behavior is the same and no additional debug output appears in the IDE UI Console. Does this output goes into some kind of file? Thanks

0

Hi Vitali,

On MacOS you should add property in /Applications/RubyMine 2.0/Contets/Info.plist file.  E.g.

<key>VMOptions</key>
<string>-Xms16m -Xmx192m -XX:MaxPermSize=120m -Xbootclasspath/p:../lib/boot.jar -ea -Druby.debug.output=true</string>

If you have MacOS Developers Tools (XCode)  installed on your Mac, you may edit *.plist files with 'Property List Editor.app'.

0

Thank you for pointing this out. I followed your instructions and this time debugging produced verbose output. Just to clarify, the problem is that if I step over all class invocations everythign is fine, however as soon as I try to step into creating an object of Puzzle class (initialize method) debugger exists, and it produces the following trace:

Processing: frame 1; step

Processing context: frame 1

Selected frame no 0

Processing context:  step

Resumed Thread #<Thread:0x100170358>

<suspended file='/Users/vitali/RubymineProjects/test2/Sudoku.rb' line='66' threadId='1' frames='2'/>

Stopping Thread #<Thread:0x100170358>

Threads equal: true

Processing: th l

<threads>

<thread id="1" status="sleep" />

</threads>

Processing: th l

<threads>

<thread id="1" status="sleep" />

</threads>

Processing: w

Processing context: w

<frames>

<frame no='1' file='/Users/vitali/RubymineProjects/test2/Sudoku.rb' line='66' current='true' />

<frame no='2' file='/Users/vitali/RubymineProjects/test2/test2.rb' line='5' />

</frames>

Processing: frame 1; v l

Processing context: frame 1

Selected frame no 0

Processing context:  v l

Exception in DebugThread loop: undefined method `[]' for nil:NilClass

Process finished with exit code 1



Note that line 5 in test2.rb is an ivocation of Sudoku::Puzzle.new and line 66 is the first line in initialize methond, which is correct.

I attached both files below, you can try it and let me know if you see the same problem.

Thanks,
Vitali

Attachment(s):
test2.rb.zip
sudoku.rb.zip
0

I was able to reproduce the problem, still need more investigation.
Thanks for the instructions, by the way, what debug gems versions do you use?

0

Hi Vitali,

After small investigation it seems that it's not a RubyMine internal problem  - I was able to reproduce it on Netbeans 6.8.beta as well.
It seems like it's a ruby-debug-ide gem problem, I've already reported this issue to the gem developer.

I should mention that debugger stops well on breakpoints, but fails when evaluating current frame's variables, thus command line rdebug works quite fine in this case.

Best regards,
Oleg

0

Hi guys,

We've finally coped with this error. As we have already told this is a ruby-debug-ide error, we've already submitted a patch for it.
Here is workaround for this: apply this patch to the file ruby-debug-ide-4.0.9/lib/ruby-debug/commands/variables.rb b/lib/ruby-debug/commands/variables.rb

Best regards,
Oleg



Attachment(s):
NoSuchMethod_exception_error_in_ruby-debug-ide.patch.zip
0

Hello Oleg,

Thank you for the patch. However on my system it did not seems to resolve the issue, unless I'm applying it incorrectly.

It's on MAC and the file that I patched is this: /Library/Ruby/Gems/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug/commands/variables.rb
Just in case, I attached the new patched version of this file. I restarted RubyMine and tried stepping into constructor of Puzzle class and debugger disconnected with the same error.

In the meantime by trial and error I figure out how to make debugger behave, at least in this example. For some misterious reason commenting out one line in sudoku.rb file makes debugger behave correctly. it's not the line in initialize method, it's in to_s method. It's the line that looks like this:

    (0..8).collect { |r| @grid[r*9, 9].pack('c9') }.join("\n").tr(BIN,ASCII)

Commenting out that line resolves debugger problems, for reasons unknown.

Did I apply the patch correctly, i.e. in the right place? And why it does it not resolve issue on my system?

Thanks again for you help



Attachment(s):
variables.rb.zip
0

Patch was applied successfully according to the file you have attached.
You should still get the errors in command line, but debugger shouldn't disconnect - this is expected behavour.
In this particullar example you have an error in to_s method implementation of Sudoku::Puzzle - it really can cause NoSuchMethodException.

(0..8).collect { |r| @grid[r*9, 9].pack('c9') }.join("\n").tr(BIN,ASCII)

This line produces such an error,  because @grid can be nil when you opt step into.
Is debugger still connected after you get some error output in console?

0

Unfortunately, debugger disconnects as soon as I try to step into initialize (constructor) method, and that method does not even include the problematic line for code I cited. That is what strange. Also running withut debugger the 'problematic' line executes correctly, because @grid is always inititialized by constructor.

0

Hi Vitali,

... that method does not even include the problematic line for code I cited. That is what strange

This is expected, because when debugger tries to evaluate all the local variables and self to show them in corresponding view. Evaluating self.to_s produces this error.
Please attach console output one more time.

0

The debug output on a console looks about the same as before when debugger disconnects. See below:

<thread id="1" status="sleep" />
</threads>
Processing: th l
<threads>
<thread id="1" status="sleep" />
</threads>
Processing: w
Processing context: w
<frames>
<frame no='1' file='/Users/vitali/RubymineProjects/test2/sudoku.rb' line='11' current='true' />
<frame no='2' file='/Users/vitali/RubymineProjects/test2/test2.rb' line='5' />
</frames>
Processing: frame 1; v l
Processing context: frame 1
Selected frame no 0
Processing context:  v l
Exception in DebugThread loop: undefined method `[]' for nil:NilClass

Process finished with exit code 1

0

The line in sudoku.rb is now 11 instead of 66 because I removed all comments, but code is exact same.

0

Vitali,

Which SDK do you use? Bundled /usr/bin/ruby or installed using MacPorts /opt/local/bin/ruby ?

0

It's Mac OSx bundled SDK (/usr/bin). MacOS X version 10.6.2. ruby version:

ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]


However bundle SDK does not come with ruby-debug-ide. so I installed it myself with "gem install". "gem list" shows this:

....
ruby-debug (0.10.3)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.9)
....
0

Vitali please take a look in folder ~/.gem/ruby/1.8/gems/. Does it contain ruby-debug-ide gem? Probably you have two gems installed (global and local)

0

Roman,

You are right, there is local gem as well (it got installed because I run gem install without sudo first, I forgot about it). Patching that file fixed the problem.

Thanks so much, you guys rock! I'm definately bying it now.

Vitali

0

Hi Vitali,

We've recently tried to apply this patch on Roman's Mac, after applying patch to variables.rb old version was backuped inside variables_orig.rb.
The presence of this file made patch useless, because all the files from folder were loaded and backup just overrided it.
Please remove backup if you have any and try again.

Hope this helps,
Oleg

0

Thanks for that advice as well. That was not my problem (see my previous post) but it's good to know. What I did is to keep the original file but give it different extension (*.orig). That seems not to interfere with the patched file, maybe only files with *.tb extensions get loaded.

0

Develop with pleasure!

0

This might be an other bug. I got the same problem, but it seems to be an issue with global variables. See the logs with "-Druby.debug.output=true" attached.

Any ideas?



Attachment(s):
debuggerlog.txt.zip
0

Hi David,

This might be an other bug. I got the same problem, but it seems to be an issue with global variables. See the logs with "-Druby.debug.output=true" attached.

Any ideas?

According to your console output you faced with different problem and patch attached in this thread has nothing to do with it.
Does your application run correctly without debug?

Regards
Oleg

0

I can recommend you to patch ruby-debug-ide gem.
Insert line
        $stderr << "Error occured while evaluating: #{to_inspect} for binding: #{b}\n#{ex.class.name}: #{ex.message}\n  #{ex.backtrace.join("\n  ")}"
in the file ruby-debug-ide-0.4.9/lib/ruby-debug/command.rb at line 130
This will help us to get more verbose error message.

Regards,
Oleg

0

Hmm, I don't have  ruby-debug-ide-0.4.9, all I have is:

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
archive-tar-minitar (0.5.2)
columnize (0.3.1)
linecache19 (0.5.11)
rack (1.0.1)
rails (2.3.5)
rake (0.8.7)
ruby-debug-base19 (0.11.23)
ruby-debug-ide19 (0.4.12)
ruby-debug19 (0.11.6)
ruby_core_source (0.1.4)
sqlite3-ruby (1.2.5)

and, I'm totally new to Ruby and this stuff. This is the second day I'm playing with Ruby and your IDE...

The application runs fine, and the next step was to try the debugger, but it doesn't seem to work... I think it is something in the debug-ide: after analyzing your patch to variables.rb, I figured out that if I disable the processing of globals (VarGlobalCommand), specifically the print_variables and debug_eval lines, then the debugger doesn't crash. It seems that it properly breaks into the program as I can see the frames etc. in the debug window.

0

So, I patched command.rb, and the output is:

Error occured while evaluating: $FILENAME for binding: #<Binding:0x45f0680>
Errno::ENOENT: No such file or directory - -p
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:130:in `eval'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:130:in `eval'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:130:in `block (2 levels) in debug_eval'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug-ide.rb:35:in `without_stderr'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:130:in `block in debug_eval'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:114:in `timeout'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:126:in `debug_eval'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/commands/variables.rb:44:in `block in execute'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/xml_printer.rb:73:in `block (2 levels) in print_variables'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/xml_printer.rb:72:in `each'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/xml_printer.rb:72:in `block in print_variables'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/xml_printer.rb:253:in `print_element'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/xml_printer.rb:69:in `print_variables'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:85:in `method_missing'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/commands/variables.rb:43:in `execute'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:74:in `block (2 levels) in process_context_commands'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:67:in `each'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:67:in `block in process_context_commands'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:66:in `catch'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:66:in `process_context_commands'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:35:in `block in process_commands'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:31:in `catch'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/processor.rb:31:in `process_commands'
  C:/Users/ncs/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug-ide.rb:151:in `block in start_control'<processingException type="Errno::ENOENT" message="No such file or directory - -p"/>
</variables>

0

and.... ruby is started with:

C:\Users\ncs\Ruby19\bin\ruby.exe -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) C:/Users/ncs/RubymineProjects/untitled1/script/server -p 3000 -b 127.0.0.1 -e development

here we have that cryptic -p , but I don't know what to do with it....

0

I have the same issue. I used to run 1.8.7 from macports and upgraded to 1.9.1 (also macports). After that and using the *19 ruby debug gems I see the same thing. It seems like a break point is hit, but when initializing the current state it gets confused and goes zombie. Process doesn't die, but the interaction with rubymine dies (have to kill it manually).

Attaching my example.

The only "-p" i can see is the argument for setting the port of the server script.

So best guess is this is a 1.9.1 related issue.

Much appreciated if you could have a look at this.

Thank you for an otherwise great product.



Attachment(s):
debug.txt.zip
0

I applied the patch mentioned here: http://rubyforge.org/tracker/index.php?func=detail&aid=27083&group_id=8883&atid=34290
and it now seems to work alright.

Not sure if that is the whole story or not but thought I'd let everyone know.

After using it for 30min it does seem like debugging in 1.9.1 is more flaky than it was in my 1.8.7 setup (i.e. sometimes it seems like it picks the wrong file in the editor when stopping at a break point. stops at right time but shows the correct line number in the wrong file). That's not necessarily a RubyMine issue at all, may well be the gems etc. Either way it's a good area to put effort into for the overall improvement of the IDE experience.

I'm using:

RubyMine 2.0
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10]
ruby-debug-base19 (0.11.23)
ruby-debug-ide19 (0.4.12)

0

Please sign in to leave a comment.