[jcifs] Deadlock in Java code.

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Wed Dec 4 17:05:18 EST 2002


What's happening is that while the JCIFS-SmbTransport thread is trying to
disconnect, another thread is trying to setup a new session but logoff,
treeDisconnect, treeConnect, and sessionSetup are all syncronized so you have:

Thread-9
  |
 locked:SmbTree x
  |      |      |
  x SmbSession:locked
                |
JCIFS-SmbTransport Thread

Originally you establish a transport, then a session over that transport, and a
tree on that session. Then your files can use send/sendTransaction on that tree.
That's the arrangement. So in this deadlock the JCIFS-SmbTransport Thread from
SmbTransport has called SmbSession.logoff (which is synchronized which
means that session object is locked) and is trying to call
SmbTree.treeDisconnect. But meanwhile the calling thread (Thread-9 in this
case) has called SmbTree.treeConnect (which is syncronized which means that
tree object is locked) and is trying to call SmbSession.sessionSetup. I'm surprised
this is reproducable.

This is the Dining Philosophers problem where the tree and session are
chopsticks :-<

> -----Original Message-----
> From:	Matthew Tippett [SMTP:matthew at casero.com]
> Sent:	Monday, December 02, 2002 11:01 AM
> To:	jcifs at lists.samba.org
> Subject:	[jcifs] Deadlock in Java code.
> 
> If a remote system goes down while a connection is active, the following
> deadlock seems to occur.  Derived by <CTRL-\> under Linux.
> 
> Regards,
> 
> Matthew
> 
> Found one Java-level deadlock:
> =============================
> "JCIFS-SmbTransport":
>    waiting to lock monitor 0x808749c (object 0x447c21a0, a 
> jcifs.smb.SmbTree),
>    which is held by "Thread-9"
> "Thread-9":
>    waiting to lock monitor 0x808814c (object 0x447ab990, a 
> jcifs.smb.SmbSession),
>    which is held by "JCIFS-SmbTransport"
> 
> Java stack information for the threads listed above:
> ===================================================
> "JCIFS-SmbTransport":
> 	at jcifs.smb.SmbTree.treeDisconnect(SmbTree.java:130)
> 	- waiting to lock <0x447c21a0> (a jcifs.smb.SmbTree)
> 	at jcifs.smb.SmbSession.logoff(SmbSession.java:121)
> 	- locked <0x447ab990> (a jcifs.smb.SmbSession)
> 	at jcifs.smb.SmbTransport.tryClose(SmbTransport.java:280)
> 	at jcifs.smb.SmbTransport.run(SmbTransport.java:403)
> 	at java.lang.Thread.run(Thread.java:536)
> "Thread-9":
> 	at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:94)
> 	- waiting to lock <0x447ab990> (a jcifs.smb.SmbSession)
> 	at jcifs.smb.SmbSession.send(SmbSession.java:85)
> 	at jcifs.smb.SmbTree.treeConnect(SmbTree.java:123)
> 	- locked <0x447c21a0> (a jcifs.smb.SmbTree)
> 	at jcifs.smb.SmbFile.connect(SmbFile.java:496)
> 	at jcifs.smb.SmbFile.connect0(SmbFile.java:466)
> 	at jcifs.smb.SmbFile.queryPath(SmbFile.java:839)
> 	at jcifs.smb.SmbFile.exists(SmbFile.java:914)
> 	at
> com.casero.eden.service.cifs.CIFSProvider.exists(CIFSProvider.java:262)
> 	at 
> com.casero.abode.file.ZoneManagerThread.pollOpzone(ZoneManagerThread.jav
> a:145)
> 	at
> com.casero.abode.file.ZoneManagerThread.run(ZoneManagerThread.java:104)
> 	at java.lang.Thread.run(Thread.java:536)
> 
> Found 1 deadlock.
> 
> 
> -----
> 
> The information contained in this message is proprietary of Casero Inc.,
> protected from disclosure, and may be privileged. The information is
> intended to be conveyed only to the designated recipient(s) of the
> message. If the reader of this message is not the intended recipient,
> you are hereby notified that any dissemination, use, distribution or
> copying of this communication is strictly prohibited and may be
> unlawful. If you have received this communication in error, please
> notify us immediately by replying to the message and deleting it from
> your computer. Thank you.
> 




More information about the jcifs mailing list