You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Thomas Wolf (Jira)" <ji...@apache.org> on 2022/08/11 22:06:00 UTC

[jira] [Commented] (SSHD-1289) Deadlock during session exit

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

Thomas Wolf commented on SSHD-1289:
-----------------------------------

Ouch. That one hurts. Of course a lock promotion from read lock to write lock is not possible.

[PR 238|https://github.com/apache/mina-sshd/pull/238] is an attempt to fix this. Somehow I'm still not too happy about all this KEX and queueing business. I have the nagging feeling that all this should be much simpler, but I can't yet put my finger on it. As an immediate fix for a serious bug PR 238 should do.

[~xvost]: Any idea for a regression test for this? And if you can, could you double-check my reasoning explained in the commit message?

> Deadlock during session exit
> ----------------------------
>
>                 Key: SSHD-1289
>                 URL: https://issues.apache.org/jira/browse/SSHD-1289
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.9.0
>            Reporter: Evgeny Pasynkov
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {code}
>    java.lang.Thread.State: WAITING
> 	at java.base@11.0.5/jdk.internal.misc.Unsafe.park(Native Method)
> 		-  waiting on java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@c50d1b2
> 	at java.base@11.0.5/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
> 	at java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:885)
> 	at java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:917)
> 	at java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1240)
> 	at java.base@11.0.5/java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:959)
> 	at org.apache.sshd.common.session.helpers.KeyExchangeMessageHandler.updateState(KeyExchangeMessageHandler.java:139)
> 	at org.apache.sshd.common.session.helpers.KeyExchangeMessageHandler.shutdown(KeyExchangeMessageHandler.java:186)
> 	at org.apache.sshd.common.session.helpers.AbstractSession.preClose(AbstractSession.java:967)
> 	at org.apache.sshd.common.util.closeable.AbstractCloseable.close(AbstractCloseable.java:94)
> 	at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.sessionClosed(AbstractSessionIoHandler.java:46)
> 	at org.apache.sshd.common.io.nio2.Nio2Session.doCloseImmediately(Nio2Session.java:283)
> 	at org.apache.sshd.common.util.closeable.AbstractCloseable.close(AbstractCloseable.java:95)
> 	at org.apache.sshd.common.io.nio2.Nio2Session.exceptionCaught(Nio2Session.java:215)
> 	at org.apache.sshd.common.io.nio2.Nio2Session.writeBuffer(Nio2Session.java:186)
> 	at org.apache.sshd.common.session.helpers.AbstractSession.doWritePacket(AbstractSession.java:1118)
> 	-  locked java.lang.Object@3423f353
> 	at org.apache.sshd.common.session.helpers.KeyExchangeMessageHandler.writeOrEnqueue(KeyExchangeMessageHandler.java:285)
> 	at org.apache.sshd.common.session.helpers.KeyExchangeMessageHandler.writePacket(KeyExchangeMessageHandler.java:228)
> 	at org.apache.sshd.common.session.helpers.AbstractSession.writePacket(AbstractSession.java:1039)
> 	at org.apache.sshd.common.session.Session.writePacket(Session.java:159)
> 	at org.apache.sshd.common.session.Session.writePacket(Session.java:145)
> 	at org.apache.sshd.common.channel.AbstractChannel$GracefulChannelCloseable.close(AbstractChannel.java:637)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:56)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:45)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable.doClose(SequentialCloseable.java:69)
> 	at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:56)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:45)
> 	at org.apache.sshd.common.future.AbstractSshFuture.lambda$notifyListener$2(AbstractSshFuture.java:162)
> 	at org.apache.sshd.common.future.AbstractSshFuture$$Lambda$352/0x0000000800890040.call(Unknown Source)
> 	at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:66)
> 	at org.apache.sshd.common.future.AbstractSshFuture.notifyListener(AbstractSshFuture.java:161)
> 	at org.apache.sshd.common.future.DefaultSshFuture.addListener(DefaultSshFuture.java:166)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:57)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:45)
> 	at org.apache.sshd.common.util.closeable.SequentialCloseable.doClose(SequentialCloseable.java:69)
> 	at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63)
> 	at org.apache.sshd.common.util.closeable.AbstractInnerCloseable.doCloseGracefully(AbstractInnerCloseable.java:41)
> 	at org.apache.sshd.common.util.closeable.AbstractCloseable.close(AbstractCloseable.java:110)
> 	at org.apache.sshd.server.channel.ChannelSession.closeShell(ChannelSession.java:916)
> 	at org.apache.sshd.server.channel.ChannelSession.lambda$prepareCommand$0(ChannelSession.java:779)
> 	at org.apache.sshd.server.channel.ChannelSession$$Lambda$414/0x00000008008fa440.onExit(Unknown Source)
> {code}
> The lock is acquired in "KeyExchangeMessageHandler.writeOrEnqueue" and then tries to re-acquire in "KeyExchangeMessageHandler.updateState"



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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