[
https://issues.apache.org/jira/browse/DIRMINA-1119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17505314#comment-17505314
]
Michael Franz commented on DIRMINA-1119:
----------------------------------------
I have experienced this same issue and after looking into it like others, I am
not 100% sure what the fix should be. This issues has been around for a while,
hopefully we can fix it soon. My issue occurs when writing out a message (SSL
-> Proxy) and reading a message (Proxy -> SSL).
I have read the code and the documentation for the SSLFilter
[https://mina.apache.org/mina-project/userguide/ch11-ssl-filter/ch11-ssl-filter.html]
and ProxyFilter (there is none). Since the SSL filter has great details and
states that "It’s even worse : you can’t process an incoming message *and* and
outgoing message at the same time." So, reads and write cannot occur at the
same time, which explains the synchronization in the SslFilter around the
SslHandler.
However, there is no documentation for the ProxyFilter and the code states it
is based on the SslFilter. It is possible that the same synchronization around
ProxyLogicHandler was just a blind copy. This leads me to believe the the
easiest fix to this issue is to remove the synchronization block in the
ProxyFilter as it is not required to protect the state of the ProxyLogicHandler
from reading and writing occurring at the same time.
If the ProxyLogicHandler (specifically the HttpSmartProxyHandler - the
implementation my issues occurs with) needs to be protected, then I fear that
the solution is to synchronize around the entire filter chain to prevent
filters locking themselves and then passing the processing to another filter
that may want to also lock itself.
Another solution would be to reimplement the SslHandler to use an SslEngine
that can both read and write at the same time.
Note:I have tried to test this, but I cannot reproduce a build following the
instructions [https://mina.apache.org/mina-project/developer-guide.html] . I
get test failures trying to ensure a valid baseline for 2.1.6 and 2.1.x.
> Deadlock when using SSL and proxy
> ---------------------------------
>
> Key: DIRMINA-1119
> URL: https://issues.apache.org/jira/browse/DIRMINA-1119
> Project: MINA
> Issue Type: Bug
> Components: Core, Filter
> Affects Versions: 2.1.3
> Reporter: Sergey Staritsin
> Assignee: Jonathan Valliere
> Priority: Critical
> Fix For: 2.2.0
>
> Attachments: Deadlock_QFJ Timer_NioProcessor.txt
>
>
> The issue seems to be the same as DIRMINA-995 (at least they have exactly the
> same symptoms and conditions).
>
> 2019-09-09 12:04:38
> Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.151-b12 mixed mode):
> Found one Java-level deadlock:
> =============================
> "NioProcessor-138":
> waiting to lock monitor 0x00000001040b88f8 (object 0xffffffff2ef07520, a
> org.apache.mina.filter.ssl.SslHandler),
> which is held by "OutputEventRoutingHandler"
> "OutputEventRoutingHandler":
> waiting to lock monitor 0x000000010386a108 (object 0xffffffff2eff53b0, a
> org.apache.mina.proxy.handlers.socks.Socks5LogicHandler),
> which is held by "NioProcessor-138"
>
> Java stack information for the threads listed above:
> ===================================================
> "NioProcessor-138":
> at
> org.apache.mina.filter.ssl.SslFilter.getSslSessionHandler(SslFilter.java:823)
> - waiting to lock <0xffffffff2ef07520> (a
> org.apache.mina.filter.ssl.SslHandler)
> at org.apache.mina.filter.ssl.SslFilter.messageReceived(SslFilter.java:499)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128)
> at
> org.apache.mina.proxy.filter.ProxyFilter.messageReceived(ProxyFilter.java:153)
> - locked <0xffffffff2eff53b0> (a
> org.apache.mina.proxy.handlers.socks.Socks5LogicHandler)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128)
> at
> org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:122)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:643)
> at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:539)
> at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.access$1200(AbstractPollingIoProcessor.java:68)
> at
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.process(AbstractPollingIoProcessor.java:1222)
> at
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.process(AbstractPollingIoProcessor.java:1211)
> at
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:683)
> at
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> "OutputEventRoutingHandler":
> at org.apache.mina.proxy.filter.ProxyFilter.writeData(ProxyFilter.java:214)
> - waiting to lock <0xffffffff2eff53b0> (a
> org.apache.mina.proxy.handlers.socks.Socks5LogicHandler)
> at org.apache.mina.proxy.filter.ProxyFilter.filterWrite(ProxyFilter.java:198)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:753)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:49)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:1146)
> at
> org.apache.mina.filter.ssl.SslHandler.flushFilterWrite(SslHandler.java:310)
> at org.apache.mina.filter.ssl.SslFilter.filterWrite(SslFilter.java:668)
> - locked <0xffffffff2ef07520> (a org.apache.mina.filter.ssl.SslHandler)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:753)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:49)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:1146)
> at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:340)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:753)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:49)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:1146)
> at
> org.apache.mina.core.filterchain.IoFilterAdapter.filterWrite(IoFilterAdapter.java:138)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:753)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:746)
> at
> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:570)
> at
> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:515)
> at quickfix.mina.IoSessionResponder.send(IoSessionResponder.java:63)
> at quickfix.Session.send(Session.java:2661)
> at quickfix.Session.sendRaw(Session.java:2590)
> at quickfix.Session.send(Session.java:2648)
> at quickfix.Session.sendToTarget(Session.java:681)
> .....
> at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:129)
> at java.lang.Thread.run(Thread.java:748)
> Found 1 deadlock.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]