A Static Analysis for Automatic Detection of Atomicity Violations in Java Programs
Multithreaded programs can have subtle errors that result from undesired interleavings of concurrent threads. A common technique to prevent these errors is to ensure that certain blocks of code are atomic. A block of code is atomic if every execution is equivalent to a serial execution in which no other thread's instructions are interleaved with the code. Atomic blocks of code are amenable to sequential reasoning and therefore significantly simpler to analyze and verify. This paper presents a system for automatically detecting atomicity violations without requiring any specifications. This requires inferring which blocks of code must be atomic as well as detecting atomicity violations. The paper first describes a synchronization pattern in programs that is likely to indicate a violation of atomicity.