[jcifs] Raise Condition in SmbFile.java

Michael B Allen mba2000 at ioplex.com
Wed Jun 2 22:06:07 GMT 2004


Michael B Allen said:
> David Fahlander said:
>> Dear colleagues, you only need to read a book about thread programming
>> to
>> see the that it is a bug. You always have to signal when a state has
>> changed
>> before you go into a wait! (In SmbFile.WriterThread.run() after setting
>> ready = true).
>
> Can you produce a thread dump or do you need to read a book for that?

Forget it. I see it. There is a race in how the WriterThread is
initialized. If WriteThread.run() isn't called until after the caller has
sent the read, called WriteThread.write(), and then looped around to
wait() a deadlock will occur when the WriterThread gets around to while(
ready ) { wait() }.

But your solution is incorrect. If the said initliaztion race occurs and
you call notify() at the top of that loop, the caller will think it's
successfully written data when it hasn't. You'll get corruption.

Will fix.

Mike


More information about the jcifs mailing list