Re: Possible deadlocking between jcifs.smb.Dfs and jcifs.smb.SmbTransport

Michael B Allen <[email protected]>
Newsgroups gmane.network.samba.java
Message-ID <CAGMFw4iHY0MYaASMOrAKmB5LT6--B1qeXhUS22tZJYXQeYWLqQ@mail.gmail.com>
On Wed, Feb 29, 2012 at 11:42 AM, Xavier Roche <[email protected]> wrote:
> Hi folks!
>
> [ Issue found in jcifs 1.3.17 ]
>
> jcifs.smb.Dfs and jcifs.smb.SmbTransport seems to be deadlocking due to
> Mutex ordering mismatch in the code.
>
> [ Is it safe to use SmbFile in two different threads simultaneously, or does
> it need to be synchronized too ? ]

Hi Xavier,

No. It is not ok to use the same SmbFile instance with more than one
thread at a time. You can use multiple threads but you just can't use
the same SmbFile object with multiple threads at the same time.

Are you seeing the deadlock with different SmbFile instances or is it
only when trying to use the same SmbFile object with multiple threads?

Mike

>
> Typical example: in the following two threads, the locking ordering is
> different
>
> Thread 1:
>        jcifs.smb.SmbTransport.getSmbSession(SmbTransport.java:126)
>                **** LOCKED(SmbTransport):
>                        synchronized SmbSession getSmbSession
>        jcifs.smb.SmbTransport.getDfsReferrals(SmbTransport.java:701)
>        jcifs.smb.Dfs.getReferral(Dfs.java:143)
>        jcifs.smb.Dfs.resolve(Dfs.java:191)
>                **** LOCKED(Dfs):
>                        public synchronized DfsReferral
>        jcifs.smb.SmbFile.doConnect(SmbFile.java:902)
>        jcifs.smb.SmbFile.connect(SmbFile.java:954)
>        jcifs.smb.SmbFile.connect0(SmbFile.java:880)
>        jcifs.smb.SmbFile.queryPath(SmbFile.java:1335)
>        jcifs.smb.SmbFile.exists(SmbFile.java:1417)
>        jcifs.smb.SmbFile.isDirectory(SmbFile.java:1490)
>        <client code>
>
> Thread 2:
>        jcifs.smb.Dfs.insert(Dfs.java:289)
>                **** LOCKED(Dfs):
>                        synchronized void insert
>        jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:556)
>        jcifs.smb.SmbTransport.send(SmbTransport.java:640)
>                **** LOCKED(SmbTransport):
>                        synchronized (this)
>        jcifs.smb.SmbSession.send(SmbSession.java:238)
>        jcifs.smb.SmbTree.send(SmbTree.java:119)
>        jcifs.smb.SmbFile.send(SmbFile.java:775)
>        jcifs.smb.SmbFile.queryPath(SmbFile.java:1363)
>        jcifs.smb.SmbFile.exists(SmbFile.java:1417)
>        jcifs.smb.SmbFile.isDirectory(SmbFile.java:1490)
>        <client code>
>
> I'm available to do more testing if necessary!
>



-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.