Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock observed in ice4j code | UPNPHarvester.java #15

Open
GoogleCodeExporter opened this issue Apr 3, 2015 · 0 comments
Open

Deadlock observed in ice4j code | UPNPHarvester.java #15

GoogleCodeExporter opened this issue Apr 3, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

We are observing deadlock using the latest version of ice4j(r302) library. We 
analysed ice4j code and could see a possibility of a deadlock occuring. Let me 
explain the scenario

When UPNPHarvester class is called, control goes to the constructor. 2 
UPNPThread instances are created and their start method is called, then the 
main thread takes lock on the rootSync object and goes into wait state.

Inside the individual thread, when each of then enters the finally block, they 
increase the finishThreads variable and call rootSync.notify() which wakes up 
the waiting main thread. The intent is that when finishThreads c=becomes 2 and 
both the UPNPThread threads have called notify only then the main thread comes 
out of the while loop and continues.

Now consider the case : main thread takes lock of rootSync object and goes into 
wait state. Out of the 2 UPNPThread threads, first one goes into finally and 
calls rootSync.notify(), main thread wakes up. Both main thread and the other 
UPNPThread thread whose start was called are now competing for lock on 
rootSynch object. If main thread gets the lock it is fine, but if the other 
UPNPThread thread gets the lock, it will call rootSync.notify() and exit. Now 
when main thread gets the lock on rootSync object, it will call wait() and go 
into the wait state indefinitely since noone will notify it.


Please let us know your view on this

Original issue reported on code.google.com by [email protected] on 13 Mar 2012 at 11:58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant