mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yumin Sang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SSHD-902) Local port forwarding: EOF is not handled properly
Date Fri, 12 Apr 2019 06:19:00 GMT

    [ https://issues.apache.org/jira/browse/SSHD-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16816002#comment-16816002
] 

Yumin Sang commented on SSHD-902:
---------------------------------

Tried the newly released version 2.2.0, the issue is still there.

In my application, SSHD is used to interact with DB. Beside the issue mentioned above, I also
meet other cases that application hangs at read0 method. One example thread stack is listed
below. It seems that SSH_MSG_CHANNEL_EOF message is not handled properly. A fix is tried as
attach code and the hang disappears. The solution is to shutdown output when receiving SSH_MSG_CHANNEL_EOF
message. Please help check if it is feasible. Thanks.

A thread stack is as blow when hang happens:

java.lang.Thread.State: RUNNABLE
at sun.nio.ch.SocketDispatcher.read0(SocketDispatcher.java:-1)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
- locked <0x27aa> (a java.lang.Object)
at oracle.net.nt.TimeoutSocketChannel.read(TimeoutSocketChannel.java:174)
at oracle.net.ns.NSProtocolNIO.doSocketRead(NSProtocolNIO.java:555)
at oracle.net.ns.NIOPacket.readHeader(NIOPacket.java:258)
at oracle.net.ns.NIOPacket.readPacketFromSocketChannel(NIOPacket.java:190)
at oracle.net.ns.NIOPacket.readFromSocketChannel(NIOPacket.java:132)
at oracle.net.ns.NIOPacket.readFromSocketChannel(NIOPacket.java:105)
at oracle.net.ns.NIONSDataChannel.readDataFromSocketChannel(NIONSDataChannel.java:91)
at oracle.jdbc.driver.T4CMAREngineNIO.prepareForUnmarshall(T4CMAREngineNIO.java:764)
at oracle.jdbc.driver.T4CMAREngineNIO.unmarshalUB1(T4CMAREngineNIO.java:429)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:407)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:268)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:655)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:270)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:91)

......

> Local port forwarding: EOF is not handled properly
> --------------------------------------------------
>
>                 Key: SSHD-902
>                 URL: https://issues.apache.org/jira/browse/SSHD-902
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.1.0
>         Environment: OS: both Windows 10 and Red Hat Enterprise Linux Server release
7.4 (Maipo) Linux 4.1.12-124.19.2.el7uek.x86_64 x86_64
> JDK: 1.8.0_201
> SSHD: 2.1.0
>            Reporter: Yumin Sang
>            Priority: Critical
>         Attachments: AbstractServerCloseTestSupport.java, ApacheServerApacheClientTest.java,
fixBasedOn2.1.0.zip, packets.PNG
>
>
> Set remote port to a real listening port but is not for DB connection. Start a local
port forwarding. Try getting a connection through the established SSH tunnel. This operation
is expected to be finished with some error, but it hangs.
> Reproduce steps:
>  # prepare a Linux server and find a listening port, such as 2049, which is not of DB
listener.
>  # get attached demo code: ApacheServerApacheClientTest.java and AbstractServerCloseTestSupport.java.
They are modified from the ones in mina-sshd-2.1.0\sshd-core\src\test\java\org\apache\sshd\common\forward.
Please replace the corresponding ones.
>  # download ojdbc8.jar from [https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html?|https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html] and
add it to classpath.
>  # set up a local port forwarding tunnel by Putty or other tools. Set the forwarded
local port to 37777, remote server/port to the server/port in step 1.
>  # run  ApacheServerApacheClientTest.java. It finishes with error like java.io.IOException:
Got minus one from a read call. This is expected behavior.
>  # change org.apache.sshd.common.forward.AbstractServerCloseTestSupport#testLocalPortForwardOneBuffer:
uncomment line "int serverPort = startLocalPF();" and comment line "int serverPort = 37777;"
>  # change org.apache.sshd.common.forward.ApacheServerApacheClientTest#createClient,
set username, host and password to the ones in step 1.
>  # run  ApacheServerApacheClientTest.java again and it hangs.
> By capturing loopback packets, it can be found the interactions are same, but SSHD make
different process from what Putty does. In attached snapshot, the "nfs" is of port 2049.
> Did a bit digging up, and it seems that EOF is not handled properly. Here is a call stack:
> handleEof:873, AbstractChannel (org.apache.sshd.common.channel)
> channelEof:498, AbstractConnectionService (org.apache.sshd.common.session.helpers)
> process:357, AbstractConnectionService (org.apache.sshd.common.session.helpers)
> doHandleMessage:626, AbstractSession (org.apache.sshd.common.session.helpers)
> handleMessage:559, AbstractSession (org.apache.sshd.common.session.helpers)
> decode:1542, AbstractSession (org.apache.sshd.common.session.helpers)
> messageReceived:520, AbstractSession (org.apache.sshd.common.session.helpers)
> messageReceived:63, AbstractSessionIoHandler (org.apache.sshd.common.session.helpers)
> handleReadCycleCompletion:339, Nio2Session (org.apache.sshd.common.io.nio2)
> onCompleted:318, Nio2Session$1 (org.apache.sshd.common.io.nio2)
> onCompleted:315, Nio2Session$1 (org.apache.sshd.common.io.nio2)
> lambda$completed$0:38, Nio2CompletionHandler (org.apache.sshd.common.io.nio2)
> run:-1, 391147216 (org.apache.sshd.common.io.nio2.Nio2CompletionHandler$$Lambda$73)
> doPrivileged:-1, AccessController (java.security)
> completed:37, Nio2CompletionHandler (org.apache.sshd.common.io.nio2)
> invokeUnchecked:126, Invoker (sun.nio.ch)
> run:218, Invoker$2 (sun.nio.ch)
> run:112, AsynchronousChannelGroupImpl$1 (sun.nio.ch)
> runWorker:1149, ThreadPoolExecutor (java.util.concurrent)
> run:624, ThreadPoolExecutor$Worker (java.util.concurrent)
> run:748, Thread (java.lang)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message