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. The paper then presents a static analysis for detecting occurrences of this pattern. We tested our system on about half a million lines of popular open source programs, and categorized the resulting atomicity warnings. Our experience demonstrates that our system is effective at detecting problems, including several previously unknown atomicity errors. Additionally, our system detects needless synchronization and stylistic problems
To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.