Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in DebugThread loop: closed stream (Ruby 2.0) #38

Closed
legal90 opened this issue Jan 26, 2014 · 27 comments · Fixed by #39
Closed

Exception in DebugThread loop: closed stream (Ruby 2.0) #38

legal90 opened this issue Jan 26, 2014 · 27 comments · Fixed by #39
Assignees

Comments

@legal90
Copy link

legal90 commented Jan 26, 2014

I'm using Jetbrains RubyMine 6.0.3 and it is required ruby-debug-ide for debugging.
I try to debug very simple command in the Vagrant project (https://github.com/mitchellh/vagrant): I try to execute vagrant help

And I got the next error:

/Users/legal/.rbenv/versions/2.0.0-p353/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/bin/rdebug-ide --disable-int-handler --port 49923 --dispatcher-port 49924 -- /Users/legal/Documents/vagrant/bin/vagrant help
Fast Debugger (ruby-debug-ide 0.4.22, debase 0.0.9) listens on 127.0.0.1:49923
19753: Exception in DebugThread loop: closed stream
Backtrace:
/Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide/interface.rb:44:in `close'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide/interface.rb:44:in `close'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide/ide_processor.rb:103:in `ensure in process_commands'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide/ide_processor.rb:103:in `process_commands'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide.rb:122:in `block in start_control'

Process finished with exit code 1

When I used Ruby 1.9.3 and debugger-xml, it was successful in the RubyMine.
But now now I've switched to Ruby 2.0 and ruby-debug-ide became required. So, the debug is not working now.

That is my Gem list: https://gist.github.com/legal90/e7841ff5d008fd34a41a

Please, help me to find the reason of this problem.

P.s. If you need some additional information about my environment - please let me know and I'll collect it.

@conradwt
Copy link

@legal90 I removed all the debug related gems from my gem file. In Rubymine 6.0.3, clicked the debugger icon and was prompted to install required debug gems for Rubymine. After the installation, things are working as expected. Thus, it appears that Rubymine 6 doesn't require one to add debug gems explicitly to the Gemfile because the documentation has the following:

http://www.jetbrains.com/ruby/webhelp/debugging.html

Note

Debugging in RubyMine does not require any additional gems. However, if there is debugger gem in your Gemfile, RubyMine checks whether debugger-xml gem is also present. If this gem is missing, RubyMine will suggest to included it to the Gemfile, to avoid conflict between the debugger gem, and the debugging gems used by RubyMine by default.

If you must install a debug gem to your Gemfile, then I would only add the following to your development block:

gem 'debugger'

@legal90
Copy link
Author

legal90 commented Jan 27, 2014

@conradwt Thank you, but I don't have any debug related gems in the Gemfile. Here is it:
https://github.com/mitchellh/vagrant/blob/master/Gemfile
https://github.com/mitchellh/vagrant/blob/master/vagrant.gemspec

P.s. My gem list has been collected after the first 'Debug' action in the Rubymine, e.q. all debug related gems was installed by Rubymine, as you have described above.

Exception still exists :(

@os97673
Copy link
Member

os97673 commented Jan 27, 2014

I've created ticket about the problem in RubyMine's tracker (http://youtrack.jetbrains.com/issue/RUBY-14880)
I've seen this and will try to fix it.

@ghost ghost assigned os97673 Jan 28, 2014
@os97673
Copy link
Member

os97673 commented Jan 28, 2014

Unfortunately, I'm unable to reproduce the problem now :(
@legal90 Is the problem still reproducible for you?
If so could you please run debugger in verbose mode (Settings|Debugger|Ruby) and provide both log of the ruby debugger and RubyMine's logs (Help|Show Log in ...)
It would be better if you'd provide them in the RubyMine's ticket I've created (I'm not sure how well github handles attachements).

@legal90
Copy link
Author

legal90 commented Jan 28, 2014

@os97673, I've attached logs to the RubyMine's ticket

@oleingemann
Copy link

Have you managed to fix this yet? I am getting the same error-message, even after removing all debugging gems from my gemfile. thx

@os97673
Copy link
Member

os97673 commented Feb 3, 2014

@olekjormo try sub-proc-init-race branch

@oleingemann
Copy link

Added this to GEMFILE

gem 'ruby-debug-ide', :git => 'git://github.com/ruby-debug/ruby-debug-ide.git', :branch => 'sub-proc-init-race'

but I still get this:

Fast Debugger (ruby-debug-ide 0.4.22, debase 0.0.9) listens on 127.0.0.1:52660
| 49640: Exception in DebugThread loop: closed stream
| Backtrace:
| /Users/myUserName/.rvm/gems/ruby-2.0.0-head/bundler/gems/ruby-debug-ide-84f79c4a74cb/lib/ruby-debug-ide/interface.rb:44:in close' 18:10:43 iver.1 | from: /Users/myUserName/.rvm/gems/ruby-2.0.0-head/bundler/gems/ruby-debug-ide-84f79c4a74cb/lib/ruby-debug-ide/interface.rb:44:inclose'

Any idea?

@os97673
Copy link
Member

os97673 commented Feb 4, 2014

@olekjormo bother :( Could you please run ruby debugger in verbose mode (--debug in command line or Settings|Debugger|Ruby|verbose in RubyMine)?

@legal90
Copy link
Author

legal90 commented Feb 6, 2014

@os97673, It is not working in my case too.
I've added to Gemfile

gem 'ruby-debug-ide', :git => 'git://github.com/ruby-debug/ruby-debug-ide.git', :branch => 'sub-proc-init-race'

And there is verbose debug output:

/Users/legal/.rbenv/versions/2.0.0-p353/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/bin/rdebug-ide --debug --disable-int-handler --port 51375 --dispatcher-port 51376 -- /Users/legal/Documents/vagrant/bin/vagrant help
Fast Debugger (ruby-debug-ide 0.4.22, debase 0.0.9) listens on 127.0.0.1:51375
Connected from 127.0.0.1
2214: Starting control thread
2214: Processing in control: start
2214: Starting: running program script
2214: Exception in DebugThread loop: closed stream
Backtrace:
/Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/lib/ruby-debug-ide/interface.rb:44:in `close'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/lib/ruby-debug-ide/interface.rb:44:in `close'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/lib/ruby-debug-ide/ide_processor.rb:103:in `ensure in process_commands'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/lib/ruby-debug-ide/ide_processor.rb:103:in `process_commands'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/lib/ruby-debug-ide.rb:124:in `block in start_control'

Process finished with exit code 1

Would you like me to send an 'idea.log' to you?

@os97673
Copy link
Member

os97673 commented Feb 6, 2014

@legal90 and what do you see in the RM's log?

@legal90
Copy link
Author

legal90 commented Feb 6, 2014

@os97673, I see only these (there are 3 entries per each debug run)

2014-02-06 11:19:20,310 [ 546363]   INFO - s.ruby.ruby.run.AbstractRunner - Executing [/Users/legal/.rbenv/versions/2.0.0-p353/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/bin/rdebug-ide --debug --disable-int-handler --port 51938 --dispatcher-port 51939 -- /Users/legal/Documents/vagrant/bin/vagrant help], working dir =[/Users/legal/Documents/vagrant]

2014-02-06 11:19:31,035 [ 557088]   INFO - s.ruby.ruby.run.AbstractRunner - Executing [/Users/legal/.rbenv/versions/2.0.0-p353/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/bin/rdebug-ide --debug --disable-int-handler --port 51941 --dispatcher-port 51942 -- /Users/legal/Documents/vagrant/bin/vagrant help], working dir =[/Users/legal/Documents/vagrant]

2014-02-06 11:19:43,246 [ 569299]   INFO - s.ruby.ruby.run.AbstractRunner - Executing [/Users/legal/.rbenv/versions/2.0.0-p353/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-84f79c4a74cb/bin/rdebug-ide --debug --disable-int-handler --port 51945 --dispatcher-port 51946 -- /Users/legal/Documents/vagrant/bin/vagrant help], working dir =[/Users/legal/Documents/vagrant]

@os97673
Copy link
Member

os97673 commented Feb 6, 2014

Hmm, it looks like I've fixed another problem which looked similar to yours :( Will look at this today or tomorrow.

@legal90
Copy link
Author

legal90 commented Feb 10, 2014

@os97673 So, is this issue still closed?
http://youtrack.jetbrains.com/issue/RUBY-14880

Debugging is one of the most important feature in Rubymine and It is so sad that it still not working with Ruby 2.x.

@os97673
Copy link
Member

os97673 commented Feb 10, 2014

the ticket is closed because it loks like the cause of the problem is in the gem.
I'm working on this but no results yet :(

@legal90
Copy link
Author

legal90 commented Feb 11, 2014

Ok, thank you very much!

@os97673
Copy link
Member

os97673 commented Feb 12, 2014

@legal90 I've added more debug output (to the branch), could you please try to reproduce the problem with it and provide debugger's log

@legal90
Copy link
Author

legal90 commented Feb 12, 2014

@os97673 Sure, that it is. But it seems that nothing has changed in the output:(

/Users/legal/.rbenv/versions/2.0.0-p353/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-83d75a9cc2ca/bin/rdebug-ide --debug --disable-int-handler --port 53099 --dispatcher-port 53100 -- /Users/legal/Documents/vagrant/bin/vagrant help
Fast Debugger (ruby-debug-ide 0.4.22, debase 0.0.9) listens on 127.0.0.1:53099
Connected from 127.0.0.1
5105: Starting control thread
5105: Processing in control: start
5105: Starting: running program script
5105: Exception in DebugThread loop: closed stream
Backtrace:
/Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-83d75a9cc2ca/lib/ruby-debug-ide/interface.rb:44:in `close'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-83d75a9cc2ca/lib/ruby-debug-ide/interface.rb:44:in `close'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-83d75a9cc2ca/lib/ruby-debug-ide/ide_processor.rb:105:in `ensure in process_commands'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-83d75a9cc2ca/lib/ruby-debug-ide/ide_processor.rb:105:in `process_commands'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-83d75a9cc2ca/lib/ruby-debug-ide.rb:124:in `block in start_control'

Process finished with exit code 1

P.s. You can try to reproduce it by yourself. Just checkout this repo: https://github.com/mitchellh/vagrant
and try to debug ./bin/vagrant --help command via Rubymine

@os97673
Copy link
Member

os97673 commented Feb 12, 2014

I was able to reproduce the exception but I'm not sure if this is the same problem as you see.
So I've added more debug output. Could you please try again.

@legal90
Copy link
Author

legal90 commented Feb 12, 2014

@os97673 now 'medvedko' is printing sometimes :-)
https://gist.github.com/legal90/0358cb6e75310b115600

@os97673
Copy link
Member

os97673 commented Feb 13, 2014

Ok, it looks like we just missed the expected exception.
But it is verfy strange in RemoteInterface.close() we resue Exception and it doesn't catch IOError, but rescue IOError helps.
So, I've updated the branch. Please try it and let me know if it helps or not.

@legal90
Copy link
Author

legal90 commented Feb 13, 2014

Sorry, but it still not working. But now there is Bad file descriptor exception:

/Users/legal/.rbenv/versions/2.0.0-p353/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/bin/rdebug-ide --debug --disable-int-handler --port 53145 --dispatcher-port 53146 -- /Users/legal/Documents/vagrant/bin/vagrant help
Fast Debugger (ruby-debug-ide 0.4.22, debase 0.0.9) listens on 127.0.0.1:53145
Connected from 127.0.0.1
2843: Starting control thread
2843: Processing in control: start
2843: Starting: running program script
2843: Exception in DebugThread loop: Bad file descriptor
Backtrace:
/Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/lib/ruby-debug-ide/interface.rb:8:in `select'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/lib/ruby-debug-ide/interface.rb:8:in `block in non_blocking_gets'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/lib/ruby-debug-ide/interface.rb:7:in `loop'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/lib/ruby-debug-ide/interface.rb:7:in `non_blocking_gets'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/lib/ruby-debug-ide/interface.rb:33:in `read_command'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/lib/ruby-debug-ide/ide_processor.rb:84:in `process_commands'
  from: /Users/legal/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/ruby-debug-ide-7c7d5865c0d8/lib/ruby-debug-ide.rb:124:in `block in start_control'

Process finished with exit code 1

@os97673
Copy link
Member

os97673 commented Feb 13, 2014

Added one more check. Try it now :)

@legal90
Copy link
Author

legal90 commented Feb 13, 2014

Now it is working better, but error still occurs:
4781: Exception in DebugThread loop: Bad file descriptor(Errno::EBADF)
Full examples: https://gist.github.com/legal90/fb030145409a0a3e214e

Statistics: I have only 1 of 5 debugging attempts failed.

@os97673
Copy link
Member

os97673 commented Feb 13, 2014

Ok, I think I've got the cause of the problem. Our code just not ready for situation when the socket will be closed on another thread. To catch all Errno::XXX we need to catch SystemCallError.
I've updated the branch.

@legal90
Copy link
Author

legal90 commented Feb 13, 2014

@os97673, great! Now it is working fine for me, thank you! I don't get errors anymore.
I hope your PR #39 will be merged soon.

@os97673
Copy link
Member

os97673 commented Feb 14, 2014

@legal90

I hope your PR #39 will be merged soon.

I hope too :) Will ping the maintainer today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants