Ensuring the correctness of multithreaded programs is difficult, due
to the potential for unexpected interactions between concurrent
threads. Much previous work has focused on detecting race conditions,
but the absence of race conditions does not by itself prevent
undesired thread interactions. We focus on the more fundamental
non-interference property of atomicity}; a method is atomic if
its execution is not affected by and does not interfere with
concurrently-executing threads. Atomic methods can be understood
according to their sequential semantics, which significantly
simplifies reasoning about program correctness.
This paper presents a dynamic analysis for detecting atomicity
violations. This analysis combines ideas from both Lipton's theory of
reduction and earlier dynamic race detectors. Experience with a
prototype checker for multithreaded Java code demonstrates that this
approach is effective for detecting errors due to unintended
interactions between threads. In particular, our atomicity checker
detects errors that would be missed by standard race detectors, and it
produces fewer false alarms on benign races that do not cause
atomicity violations.