ruby-debug / ruby-debug-ide

An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans and RubyMine.
https://www.jetbrains.com/ruby/features/ruby_debugger.html
Other
370 stars 83 forks source link

Fatal exception in DebugThread loop: closed stream #189

Open amiracam opened 4 years ago

amiracam commented 4 years ago

Stack encountered upon starting my project with in IDEA in debug mode, see below. Interesting to note that on line 139 for rubydebugide.rb the class DebugThread is not recognized by IDEA as being present.

Breakpoints fail to engage which makes sense i.e. its stated that the debug stream is closed.

Is there anything that I can do to provide further info to help debug this issue ?

thanks

C:\jruby-9.2.11.1\bin\jruby.exe -J-cp C:\Users\Charles\IdeaProjects\DBIX2\build\resources\main;C:\Users\Charles\IdeaProjects\DBIX2\gems\dbix4Test-allgems.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.vertx\vertx-lang-ruby\3.8.4\d40d9a583ffa6cc13b5c3c565866e223a76d61da\vertx-lang-ruby-3.8.4.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.vertx\vertx-web\3.8.4\15ddd6bc49462bc2f44827f634a14155a55435d2\vertx-web-3.8.4.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.vertx\vertx-core\3.8.4\f046076d52d93fb523104fe9470819cec7537f69\vertx-core-3.8.4.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\org.jruby\jruby-complete\9.2.8.0\2dbdff9d9f4142e4a0bc2b743ded9487a80459ef\jruby-complete-9.2.8.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.oracle.ojdbc\ojdbc8\19.3.0.0\967c0b1a2d5b1435324de34a9b8018d294f8f47b\ojdbc8-19.3.0.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\org.postgresql\postgresql\42.2.8\6f394c7df5600d11b221f356ff020440d2ece44f\postgresql-42.2.8.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.microsoft.sqlserver\mssql-jdbc\7.4.1.jre8\934e92cd5eac5f0edb0298f13693e49e76fdd917\mssql-jdbc-7.4.1.jre8.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.25\8b6e01ef661d8378ae6dd7b511a7f2a33fae1421\snakeyaml-1.25.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.vertx\vertx-lang-ruby-gen\3.8.4\f190d41e9ddf36c0443a6a64093668f723c0740d\vertx-lang-ruby-gen-3.8.4.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.vertx\vertx-web-common\3.8.4\95df86101134455c2c7048bcd3734bb0e81b7d9f\vertx-web-common-3.8.4.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.vertx\vertx-auth-common\3.8.4\6cce0e75b7fc4c1dcab7ba0a6a0854d7b5d6215a\vertx-auth-common-3.8.4.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.vertx\vertx-bridge-common\3.8.4\13a431c59b3c580ace21c7ba0fe3d183104ce78a\vertx-bridge-common-3.8.4.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-handler-proxy\4.1.42.Final\7b816d9f37ddcb68f6c1b9b0d7b5a98bfac40911\netty-handler-proxy-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-codec-http2\4.1.42.Final\819e7b5f2005770cf7558c04276fff080331c6df\netty-codec-http2-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-codec-http\4.1.42.Final\5f71267aa784d0e6c5ec09fb988339d244b205a0\netty-codec-http-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-handler\4.1.42.Final\fc6546be5df552d9729f008d8d41a6dee28127aa\netty-handler-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-resolver-dns\4.1.42.Final\385e8b85dce81f8ac61d8b161c5b39020b5d789f\netty-resolver-dns-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-transport\4.1.42.Final\857502e863c02c829fdafea61c3fda6bda01d0af\netty-transport-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-buffer\4.1.42.Final\6e6fc9178d1f1401aa0d6b843341efb91720f2cd\netty-buffer-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-resolver\4.1.42.Final\ccaacf418a9e486b65e82c47bed66439119c5fdb\netty-resolver-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-common\4.1.42.Final\e02700b574d3a0e2100308f971f0753ac8700e7c\netty-common-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.9.1\211dfab27bdd15a569247fee4690a07a177044f8\jackson-databind-2.9.9.1.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.9\bfff5af9fb8347d26bbb7959cb9b4fe9a2b0ca5e\jackson-core-2.9.9.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.oracle.ojdbc\ucp\19.3.0.0\796b661b0bb1818b7c04171837356acddcea504c\ucp-19.3.0.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.oracle.ojdbc\oraclepki\19.3.0.0\e52a34f271c6c62ee1a73b71cc19da5459b709f\oraclepki-19.3.0.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.oracle.ojdbc\osdt_cert\19.3.0.0\c134652fdcb17ff72963d386efd8ade902d2eaff\osdt_cert-19.3.0.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.oracle.ojdbc\osdt_core\19.3.0.0\2e01c262879c97de876c238966eb1da48542f2e8\osdt_core-19.3.0.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.oracle.ojdbc\simplefan\19.3.0.0\bcbfbb3cc529995f33c8694eb7cbc605c129e4e6\simplefan-19.3.0.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.oracle.ojdbc\ons\19.3.0.0\cf3f3ef525c61a27fe9952652a156ddd738b1cd5\ons-19.3.0.0.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-codec-socks\4.1.42.Final\dd355f01dc00f93aaebe805b05026d7cf57c60ec\netty-codec-socks-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-codec\4.1.42.Final\b1d5ed85a558fbbadc2783f869fbd0adcd32b07b\netty-codec-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\io.netty\netty-codec-dns\4.1.42.Final\67528de727bae6c4a2ff4dce0afa2a4c3c8f60bd\netty-codec-dns-4.1.42.Final.jar;C:\Users\Charles.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\Charles\IdeaProjects\DBIX2\src\main\jruby -X+O -J-Djruby.compile.mode=OFF -J-Djruby.debug.fullTrace=true C:\jruby-9.2.11.1\lib\ruby\gems\shared\gems\ruby-debug-ide-0.7.1.beta3\bin\rdebug-ide --key-value --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 54586 --host 0.0.0.0 --dispatcher-port 54587 -- C:/Users/Charles/IdeaProjects/DBIX2/src/main/jruby/init.rb Evaluation memory limit is ineffective in JRuby and MRI < 2.0 Fast Debugger (ruby-debug-ide 0.7.1.beta3, ruby-debug-base 0.11.0, file filtering is supported) listens on 0.0.0.0:54586 Fatal exception in DebugThread loop: closed stream Backtrace: org/jruby/ext/socket/RubyTCPServer.java:157:in accept' from: :1:inblock in ' Exception in thread "Ruby-0-Thread-1: C:/jruby-9.2.11.1/lib/ruby/gems/shared/gems/ruby-debug-ide-0.7.1.beta3/lib/ruby-debug-ide.rb:139" java.lang.NullPointerException at org.jruby.internal.runtime.ThreadService.getMainThread(ThreadService.java:233) at org.jruby.RubyThread.exceptionRaised(RubyThread.java:1815) at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:112) at java.lang.Thread.run(Thread.java:748)

**what's interesting is that in the following offending code:

DebugThread is not recognized by IDEA as being available**

def _start_control_common(host, port, socket_path, notify_dispatcher) raise "Debugger is not started" unless started? return if @control_thread @control_thread = DebugThread.new do begin if socket_path.nil?

127.0.0.1 seemingly works with all systems and with IPv6 as well.

"localhost" and nil have problems on some systems.

host ||= '127.0.0.1'

        server = notify_dispatcher_if_needed(host, port, notify_dispatcher) do |real_port, port_changed|
          s = TCPServer.new(host, real_port)
          print_greeting_msg $stderr, host, real_port, port_changed ? "Subprocess" : "Fast" if defined? IDE_VERSION
          s
        end
      else
        raise "Cannot specify host and socket_file at the same time" if host
        File.delete(socket_path) if File.exist?(socket_path)
        server = UNIXServer.new(socket_path)
        print_greeting_msg $stderr, nil, nil, "Fast", socket_path if defined? IDE_VERSION
      end

      return unless server

      while (session = server.accept)
        if Debugger.cli_debug
          if session.peeraddr == 'AF_INET'
            $stderr.puts "Connected from #{session.peeraddr[2]}"
          else
            $stderr.puts "Connected from local client"
          end
        end
        dispatcher = ENV['IDE_PROCESS_DISPATCHER']
        if dispatcher
          ENV['IDE_PROCESS_DISPATCHER'] = "#{session.peeraddr[2]}:#{dispatcher}" unless dispatcher.include?(":")
          ENV['DEBUGGER_HOST'] = host
        end
        begin
          @interface = RemoteInterface.new(session)
          self.handler = EventProcessor.new(interface)
          IdeControlCommandProcessor.new(interface).process_commands
        rescue StandardError, ScriptError => ex
          bt = ex.backtrace
          $stderr.printf "#{Process.pid}: Exception in DebugThread loop: #{ex.message}(#{ex.class})\nBacktrace:\n#{bt ? bt.join("\n  from: ") : "<none>"}\n"
          exit 1
        end
      end
    rescue
      bt = $!.backtrace
      $stderr.printf "Fatal exception in DebugThread loop: #{$!.message}\nBacktrace:\n#{bt ? bt.join("\n  from: ") : "<none>"}\n"
      exit 2
    end
  end
end
amiracam commented 4 years ago

I encounter this issue in Ubuntu as well i.e. by testing with my Jruby Vertx project, however testing a simple script doesn't generate the issue, perhaps Vertx concurrency is not compatible with ruby-debug-base, I have no clue