![]() The method of our interest is findMonitorDeadlockedThreads, or, if you are using Java 6,findDeadlockedThreads. I recommend you to check all of the methods as there are many useful operations for monitoring the performance of your application in case you are not using an external tool. Java 5 introduced ThreadMXBean - an interface that provides various monitoring methods for threads. Although some statical analysis libraries exist that can help us detect the possible deadlocks, it is still necessary to be able to detect them during runtime and get some information which can help us fix the issue or alert us so we can restart our application or whatever.ĭetect deadlocks programmatically using ThreadMXBean class The reason for this is it’s not practical to test all possible interleavings of a program’s threads. To make things worse, deadlocks usually manifest in production under the heaviest load, and are very hard to spot during testing. They can be very hard to detect during development, and they usually require restart of the application in order to recover. locked 0x00000007ac3b1970 (a )ĭeadlocks are situations in which two or more actions are waiting for the others to finish, making all actions in a blocked state forever. : BLOCKED (on object monitor)Īt $n(DeadLockSimulator.java:29) Thread dump captured on the above code would look like: In the above code following is the execution path of ‘FirstThread‘:įollowing is the execution path of ‘SecondThread‘: Private static class FirstThread extends Thread Public static Object Lock2 = new Object() Public static Object Lock1 = new Object() Here is a sample code which simulates deadlock condition in-between two threads: Read the full paperĪ compositional deadlock detector for Android Java AcknowledgementsĪdditional thanks to the co-authors of this research, James Brotherston, Paul Brunet, and Max Kanovich, all at University College London (UCL).If deadlock happens in a JVM, the only way to recover from the situation is to restart the JVM. Our approach achieves this goal while also making the analyzer sufficiently scalable so that it can be deployed on the massive codebases at Meta. Deadlocks are also very difficult bugs to diagnose because thread scheduling is essentially non-deterministic and, thus, a test might need to run thousands or millions of times in order to exhibit the problem.ĭetecting deadlocks statically, without running or even building the code is, therefore, extremely valuable. Why it matters:Ī deadlock is typically an unrecoverable error. In other words, in this language, we can find all the deadlocks without false positives. In our paper, we also prove that our analysis is sound and complete for an abstract programming language that has only non-deterministic control. It is this heuristic that enables our analysis to scale. Then, based on that data, it applies a heuristic that locates methods outside the revision that could potentially deadlock with one of the methods in the revision. Instead, it first processes all methods in the revision’s modified files. To be fast and efficient, our tool avoids analyzing all source files in an app. This data, computed across all methods, is enough to let us answer the question of whether a deadlock is possible between two concurrent methods. A critical pair (A,B) records the following fact: The method tries to acquire lock B, and at that time, it’s already holding precisely locks in set A. The central part of the summary is the set of critical pairs of the method. This is done in a compositional manner: Each method is summarized once, at most, and its summary is used in the summarization of its callers, ensuring predictable high performance. For each method, the analyzer computes a summary of how the method behaves in terms of lock acquisition and release, as well as whether the method will run on the main thread or on a background thread. We used abstract interpretation techniques to design our analyzer. Our analyzer is open source and forms part of the Infer static analysis framework. ![]() ![]() In the last two years, developers have actioned over 200 fixes in response to deadlock reports, at a fix rate of around 54 percent. We have deployed our analyzer in Meta’s continuous integration system, where it scans every commit to the Android app family. What distinguishes our analyzer from past research is its ability to analyze revisions in codebases with hundreds of millions of lines of code. We’ve developed a new static analyzer that catches deadlocks in Java code for Android without ever running the code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |