[
https://issues.apache.org/jira/browse/SSHD-249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Guillaume Nodet resolved SSHD-249.
----------------------------------
Resolution: Fixed
Fix Version/s: 0.10.0
Assignee: Guillaume Nodet
Fixed with
https://git-wip-us.apache.org/repos/asf?p=mina-sshd.git;a=commit;h=9a27e728436965c388be95211297853d2dd07f37
> Data race in AbstractSession.close() may lead to NPE and blocks during
> shutdown
> -------------------------------------------------------------------------------
>
> Key: SSHD-249
> URL: https://issues.apache.org/jira/browse/SSHD-249
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 0.9.0
> Reporter: Marian Seitner
> Assignee: Guillaume Nodet
> Priority: Critical
> Fix For: 0.10.0
>
>
> The issue will be described in more details because a) it was enthralling to
> debug and reproduce b) it might be interesting for others to fully understand
> c) the probability to discover it is quite low, nonetheless it happened
> during an aggressive integration test.
> The symptoms were a NullPointerException in AbstractSession.close() line 335
> and a blocking thread which was supposed to shut down a server instance.
> After looking at the code line 331 was identified as critical section as it
> was the only place where a null value could have sneaked into the array.
> In order to run into this problem two preconditions have to be met: a) the
> server is currently shutting down and thus trying to close all channels and
> sessions b) one or more channels are unregistered at the same time.
> What happens in line 331:
> // Channel[] channelToClose = channels.values().toArray(new
> Channel[channels.values().size()]);
> In case of unlucky timing the (first) call to channels.values() returns a
> larger set (whose size is used to initialize the array) than the second call,
> which is used to actually populate the array, so one or more array elements
> are null.
> This single problem illustrates three issues:
> * Atomic treatment of non-atomic operations
> * Unguarded access to the channels map through (un)registerChannel() etc.
> * Incorrect exception handling (line 340 never gets called due to missing
> latch.decrementAndGet() calls, so the IoSessionCloser is never executed
> (which then leads to the blocking thread))
> If somehow manageable a patch will be provided.
--
This message was sent by Atlassian JIRA
(v6.1#6144)