Giovanni Liva

Extracting Parallel Control Flow Graphs with Synchronization Information from Java Program

Developers spend a significant amount of their time on understanding programs, especially if these programs are large and use multi-threading. Regarding such programs, one key aspect concerns the understanding of how shared data is accessed by the different threads, for instance to prevent race conditions. Most of the existing approaches address this issue by using dynamic analysis of execution traces. However, dynamic analysis has two main shortcomings: first, the program needs to be executable, and, second, execution traces typically do not cover all possible scenarios. In this paper, we propose an approach that uses static analysis to extract Parallel Control Flow Graphs with Synchronization Information (PCFGs-SI) from source code. While CFGs help to understand the control flow of source code statements executed in parallel, synchronization edges highlight the shared access to critical code blocks protected by a locking mechanism. We evaluated our approach and heuristics with five open source Java projects that use two specific locking mechanisms to handle the communication between different threads, namely synchronized code blocks and synchronized methods. The results show that our approach extracts synchronization edges between synchronized code blocks with a precision of 97.50% and recall of 99.50%. Edges between calls to synchronized methods are extracted with a precision of 100% and recall of 96.35%. We demonstrate the usefulness of our approach with two examples, in which our approach is used to detect shortcomings in the use of locking in Java.

{{FIG_CAPTION}}
Excerpt of the PCFGs-SI extracted from the Jetty project showing three mustbe-synchronized method edges between the two doStop methods of the classes ClientContainer and WebSocketClient. Nodes labeled with "..." represent groups of statements not relevant for the example.
PDF code Tool

@inproceedings{liva2017pcfg,
    Author = {G. Liva, F. Spegni, L. Spalazzi, A. Bollin, M. Pinzger},
    Title = {Extracting Parallel Control Flow Graphs with Synchronization Information from Java Program},
    Year = {2017},
    Booktitle = {Tecnical Report},
    Pages = {10}
}