[ 
https://issues.apache.org/jira/browse/SSHD-921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Goldstein Lyor resolved SSHD-921.
---------------------------------
       Resolution: Fixed
    Fix Version/s: 2.3.0

Closing this issue - let's continue discussion on SSHD-923

> OutOfMemory Error in extreme situations
> ---------------------------------------
>
>                 Key: SSHD-921
>                 URL: https://issues.apache.org/jira/browse/SSHD-921
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 1.7.0, 2.0.0
>            Reporter: Zhenliang Su
>            Assignee: Goldstein Lyor
>            Priority: Major
>             Fix For: 2.3.0
>
>         Attachments: Main.java, jstack.txt
>
>
> The demo code run in my local machine.
>  When I 'ssh root@127.0.0.1 -p 2233', my demo will use the agent forwarding 
> feature to login 10.10.16.201.
>  In most cases, it's ok. But in few cases, for example, client disconnect 
> suddenly, it will lead to OutOfMemory Error.
>  To simulate this scenario of OutOfMemory Error, I did some trick to the sshd 
> code:
>  1. In org.apache.sshd.common.future.DefaultSshFuture#setValue:
> {code:java}
> public void setValue(Object newValue) {
>       // to simulate race condition
>       try {
>               Thread.sleep(10);
>       } catch (Exception e) {
>               // ignore
>       }
>         synchronized (lock) {
>             // Allow only once.
>             if (result != null) {
>                 return;
>             }
>             result = (newValue != null) ? newValue : GenericUtils.NULL;
>             lock.notifyAll();
>         }
>         notifyListeners();
>     }
> {code}
> 2. In org.apache.sshd.agent.local.AgentForwardedChannel#doWriteData:
> {code:java}
>  protected void doWriteData(byte[] data, int off, long len) throws 
> IOException {
>         ValidateUtils.checkTrue(len <= Integer.MAX_VALUE, "Data length 
> exceeds int boundaries: %d", len);
>         Buffer message = null;
>         synchronized (receiveBuffer) {
>             receiveBuffer.putBuffer(new ByteArrayBuffer(data, off, (int) 
> len));
>             // to simulate client disconnect suddenly
>             if (false && receiveBuffer.available() >= 4) {
>                 off = receiveBuffer.rpos();
>                 len = receiveBuffer.getInt();
>                 receiveBuffer.rpos(off);
>                 if (receiveBuffer.available() >= (4 + len)) {
>                     message = new ByteArrayBuffer(receiveBuffer.getBytes());
>                     receiveBuffer.compact();
>                 }
>             }
>         }
>         if (message != null) {
>             synchronized (messages) {
>                 messages.offer(message);
>                 messages.notifyAll();
>             }
>         }
>     }
> {code}
> After two munites, my console displayed 
> '[sshd-SshClient[720b3c53]-timer-thread-1] INFO 
> org.apache.sshd.client.session.ClientSessionImpl - 
> Disconnecting(ClientSessionImpl[root@/10.10.16.201:8022]): 
> SSH2_DISCONNECT_PROTOCOL_ERROR - Session has timed out waiting for 
> authentication after 120000 ms.' every second, and finally lead to 
> OutOfMemory Error.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to