Proceedings of ISP RAS


Detecting Race Conditions in Java Programs Using Dynamic Analysis

M. Ermakov (ISP RAS, Moscow, Russia)
S. Vartanov (ISP RAS, Moscow, Russia)

Abstract

Multithreading support is one of Java programming language built-in features. Synchronization defects are a serious issue despite the extensive thread processing API provided by standard classes. One of the most common synchronization defects is a race condition. It arises when two different threads read and modify shared data and data access order is not fixed. This paper focuses on an approach to automatically detect race conditions using dynamic analysis. The main advantage of dynamic analysis is the lack of false positives if program under analysis fits a number of requirements. Our approach for dynamic analysis uses static bytecode instrumentation to extract execution trace at run-time which allows to track usage for thread synchronization methods and functions. Generated trace is a concrete execution model which is processed to identify happen-before relations and lock sets for possible data race detection. We use Coffee Machine tool for static instrumentation. Static instrumentation approach is applicable even to virtual machines which do not provide support for dynamic instrumentation. We use ThreadSanitizer Offline to process generated trace and detect race conditions. While debug information in bytecode is unnecessary it provides more precise error messages. Described tool chain has been tested on a set of open source projects.

Keywords

dynamic analysis, race condition, synchronization defects

Edition

Proceedings of the Institute for System Programming, vol. 27, issue 2, 2015, pp. 39-52.

ISSN 2220-6426 (Online), ISSN 2079-8156 (Print).

DOI: 10.15514/ISPRAS-2015-27(2)-3

Full text of the paper in pdf (in Russian) Back to the contents of the volume