Uploaded image for project: 'MINA SSHD'
  1. MINA SSHD
  2. SSHD-451

sshd-core DefaultTcpIpForwarder channel deadlocks on JRE 1.6.x

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • 0.10.0, 0.14.0, 1.0.0
    • None
    • Java SE 6 [1.6.0_65-b14-466.1]
      Java SE 8 [1.8.0_51-b16]

    Description

      I have a CentOS 6.4 system running httpd-2.4.9 on port 8000.

      From this system, if I ssh to a MINA sshd-core 0.14.0 server running on Java SE 6 1.6.0_65-b14-466.1 using the following invocation

      /usr/bin/ssh -R *:8000:localhost:8000 -p 2000 -N username@local-mina-server

      I can reliably deadlock a remote forward channel after approximately five requests to localhost:8000 on the system running MINA.

      After these requests I see one last line on the MINA server

      2015-04-22 10:11:10,406 | TRACE | NioProcessor-3   | TcpipClientChannel               | org.apache.sshd.client.channel.AbstractClientChannel              195 | Waiting for lock on channel TcpipClientChannel[id=9, recipient=0], mask=130, cond=0
      

      and then I cease to be able to access the remotely forwarded port until after the MINA server has been restarted, even if I restart the client connection.

      I believe the issue is related to this method in DefaultTcpipForwarder.java:

              public void messageReceived(IoSession session, Readable message) throws Exception {
                  TcpipClientChannel channel = (TcpipClientChannel) session.getAttribute(TcpipClientChannel.class);
                  Buffer buffer = new Buffer();
                  buffer.putBuffer(message);
                  channel.waitFor(ClientChannel.OPENED | ClientChannel.CLOSED, Long.MAX_VALUE);
                  channel.getInvertedIn().write(buffer.array(), buffer.rpos(), buffer.available());
                  channel.getInvertedIn().flush();
              }
      

      The channel lock wait request is given with a timeout of Long.MAX_VALUE, which seems unlikely to ever return in a synchronous environment like JRE 1.6.x. Initial testing indicates that a timeout of 5 seconds appears to fix the issue, but this may have unforeseen consequences that I haven't run into yet.

      I cannot reproduce the issue on MINA SSHD 0.8.0, or when using JRE 1.7.x.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sgardner Sam Gardner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: