The research team at Meta has developed a new static analyzer that catches deadlocks in Java code for Android without ever running the app. What distinguished this work from past efforts is its ability to analyze revisions within large software libraries with hundreds of millions of lines–enough time and space so problems can be found before they manifest themselves as bugs or crashes. The proposed analyzer is open-sourced and forms part of the Infer static analysis framework.
Using abstract interpretation techniques, the proposed analyzer has been designed to summarize how each method behaves when acquiring locks and releasing them and whether it can run on the main thread or background task. This is done elegantly by compounding all behaviors into one summary that reflects what callers will be affected if their operation depends upon this particular piece of code being fast enough for them not to experience lags while running through various parts within your application’s workflow process.
This tool takes a different approach by not analyzing all source files in an app. Instead, it starts with the revisions’ modified methods first and uses that data for its analysis – which can be scalable because of this heuristic.
The team’s research proves that their analysis is sound and complete for a non-deterministic programming language, which means it can detect all deadlocks without false positives.
The static detection of deadlocks has been very valuable in analyzing and diagnosing. Our approach achieves this goal while also making it sufficiently scalable to deploy analyzers on large codebases.
Paper: https://discovery.ucl.ac.uk/id/eprint/10140070/1/deadlocks_final.pdf
Reference: https://engineering.fb.com/2022/03/08/android/deadlock-detector-for-android-java/