[jcifs] bugs in JCIFS 1.2.9

Tim Struyf tim.struyf at roots.be
Wed Nov 29 17:51:48 GMT 2006


Mike,
 
I ran your testcase and I get the same output as your email below, if i run it from the console!
 
However if I run this testcase in eclipse in debug mode I still see a lot of writer threads, all in object.wait() , waiting for a notify().
So I believe there might still be something wrong... (at least if you trust the eclipse debugger...)
 
i find it very weird that eclipse is showing these threads...
(with the w.interrupt implemented, these threads get closed correctly and no threads remain in object.wait)
 
regards,
Tim

________________________________

Van: Michael B Allen [mailto:mba2000 at ioplex.com]
Verzonden: vr 24/11/2006 17:24
Aan: Tim Struyf
CC: jcifs at lists.samba.org
Onderwerp: Re: [jcifs] bugs in JCIFS 1.2.9



The following thread should cause the writer thread to exit.

   2139         try {
   2140             copyTo0( dest, b, bsize, w, req, resp );
   2141         } finally {
   2142             w.write( null, -1, null, 0 );
   2143         }

I cannot reproduce this problem. I think you are confusing the writer
thread with the Transport threads. You will need to get a thread dump
to verify this.

Run the attached example like:

$ java -Djcifs.properties=../miallen.prp CopyToTest smb://ts0.win.net/tmp/bogus.txt smb://nano.foo.net/pub/bogus.txt
jcifs.smb.SmbException: The system cannot find the file specified.
        at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:511)
        at jcifs.smb.SmbTransport.send(SmbTransport.java:588)
        at jcifs.smb.SmbSession.send(SmbSession.java:239)
        at jcifs.smb.SmbTree.send(SmbTree.java:109)
        at jcifs.smb.SmbFile.send(SmbFile.java:690)
        at jcifs.smb.SmbFile.queryPath(SmbFile.java:1202)
        at jcifs.smb.SmbFile.copyTo0(SmbFile.java:1950)
        at jcifs.smb.SmbFile.copyTo(SmbFile.java:2140)
        at CopyToTest.run(CopyToTest.java:17)

<get a thread dump [1]>

Full thread dump Java HotSpot(TM) Client VM (1.4.2_08-b03 mixed mode):

"Transport2" daemon prio=1 tid=0x093bbae8 nid=0x3eea runnable [4be3000..4be4228]
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at jcifs.util.transport.Transport.readn(Transport.java:29)
        at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:352)
        at jcifs.util.transport.Transport.loop(Transport.java:100)
        at jcifs.util.transport.Transport.run(Transport.java:261)
        at java.lang.Thread.run(Thread.java:534)

"Transport1" daemon prio=1 tid=0x093b77d0 nid=0x3eea runnable [2ef6000..2ef7228]
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at jcifs.util.transport.Transport.readn(Transport.java:29)
        at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:352)
        at jcifs.util.transport.Transport.loop(Transport.java:100)
        at jcifs.util.transport.Transport.run(Transport.java:261)
        at java.lang.Thread.run(Thread.java:534)

"Signal Dispatcher" daemon prio=1 tid=0x0925d8d8 nid=0x3eea waiting on condition [0..0]

"Finalizer" daemon prio=1 tid=0x09248e38 nid=0x3eea in Object.wait() [5a6000..5a6228]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xae3573f0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
        - locked <0xae3573f0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=1 tid=0x09248290 nid=0x3eea in Object.wait() [4eb000..4eb228]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xae357290> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:429)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
        - locked <0xae357290> (a java.lang.ref.Reference$Lock)

"main" prio=1 tid=0x092129a0 nid=0x3eea waiting on condition [bff37000..bff3729c]
        at java.lang.Thread.sleep(Native Method)
        at CopyToTest.main(CopyToTest.java:27)

"VM Thread" prio=1 tid=0x09247030 nid=0x3eea runnable

"VM Periodic Task Thread" prio=1 tid=0x092600d8 nid=0x3eea waiting on condition
"Suspend Checker Thread" prio=1 tid=0x0925cf20 nid=0x3eea runnable

You can see above there is no "JCIFS-WriterThread" listed.

Now wait 20 seconds for the Transport threads to exit and do a thread
dump again:

Full thread dump Java HotSpot(TM) Client VM (1.4.2_08-b03 mixed mode):

"Signal Dispatcher" daemon prio=1 tid=0x0925d8d8 nid=0x3eea runnable [0..0]

"Finalizer" daemon prio=1 tid=0x09248e38 nid=0x3eea in Object.wait() [5a6000..5a6228]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xae3573f0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
        - locked <0xae3573f0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=1 tid=0x09248290 nid=0x3eea in Object.wait() [4eb000..4eb228]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xae357290> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:429)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
        - locked <0xae357290> (a java.lang.ref.Reference$Lock)

"main" prio=1 tid=0x092129a0 nid=0x3eea waiting on condition [bff37000..bff3729c]
        at java.lang.Thread.sleep(Native Method)
        at CopyToTest.main(CopyToTest.java:27)

"VM Thread" prio=1 tid=0x09247030 nid=0x3eea runnable

"VM Periodic Task Thread" prio=1 tid=0x092600d8 nid=0x3eea waiting on condition
"Suspend Checker Thread" prio=1 tid=0x0925cf20 nid=0x3eea runnable

Now you can see only VM threads are left.

AFAICT everything is working perfectly.

Or just try to add a 20 second sleep to your test and you'll see the
Transport threads exit. You can make them close quicker by reducing
jcifs.smb.client.soTimeout.

Mike

[1] To get a thread dump on Windows, run your program on the console
and press <ctrl><break> (on Unix it's <ctrl>\).




More information about the jcifs mailing list