Skip to main content
QUICK REVIEW

[Paper Review] Preventing Atomicity Violations with Contracts

Diogo Sousa, Ricardo J. Dias|arXiv (Cornell University)|May 12, 2015
Distributed systems and fault toleranceComputer Science50 references5 citations
TL;DR

This paper proposes contracts for concurrency to prevent atomicity violations in concurrent programs by specifying which sequences of method calls must be executed atomically. Using a static analysis based on control flow and data flow, the approach verifies that client programs respect these contracts, ensuring correctness even when individual methods are synchronized. The method was validated on real-world software, including a critical bug in Apache Tomcat 6.0 that was promptly fixed.

ABSTRACT

Software developers are expected to protect concurrent accesses to shared regions of memory with some mutual exclusion primitive that ensures atomicity properties to a sequence of program statements. This approach prevents data races but may fail to provide all necessary correctness properties.The composition of correlated atomic operations without further synchronization may cause atomicity violations. Atomic violations may be avoided by grouping the correlated atomic regions in a single larger atomic scope. Concurrent programs are particularly prone to atomicity violations when they use services provided by third party packages or modules, since the programmer may fail to identify which services are correlated. In this paper we propose to use contracts for concurrency, where the developer of a module writes a set of contract terms that specify which methods are correlated and must be executed in the same atomic scope. These contracts are then used to verify the correctness of the main program with respect to the usage of the module(s). If a contract is well defined and complete, and the main program respects it, then the program is safe from atomicity violations with respect to that module. We also propose a static analysis based methodology to verify contracts for concurrency that we applied to some real-world software packages. The bug we found in Tomcat 6.0 was immediately acknowledged and corrected by its development team.

Motivation & Objective

  • To address atomicity violations that occur when composing synchronized methods from third-party modules, even when individual methods are thread-safe.
  • To provide a formal mechanism for specifying which sequences of method calls must be executed atomically to preserve correctness.
  • To develop a static analysis technique that verifies client programs conform to module contracts, ensuring atomicity of correlated operations.
  • To improve software reliability in concurrent systems by enabling early detection of atomicity violations through contract-based verification.

Proposed method

  • The authors define contracts as star-free regular expressions over public methods, specifying sequences that must be executed atomically to prevent violations.
  • A static analysis extracts control and data flow information from client programs to determine the possible sequences of module method calls.
  • The analysis checks whether all possible call sequences in the client program are subsumed by the contract's specified sequences, ensuring atomicity.
  • A prototype implementation uses ICFinder for interprocedural control flow analysis and applies filtering to reduce false positives from broad patterns.
  • The approach integrates with existing design-by-contract methodologies, extending them to handle concurrency-specific correctness properties.
  • The verification process is fully static, avoiding the overhead and imprecision of dynamic analysis while maintaining high precision.

Experimental results

Research questions

  • RQ1How can atomicity violations be systematically prevented when composing synchronized methods from third-party modules?
  • RQ2What formal specification mechanism can express which sequences of method calls must be atomic to preserve correctness?
  • RQ3Can a static analysis efficiently and precisely verify that client programs respect concurrency contracts?
  • RQ4How effective is the proposed method in detecting real-world atomicity violations in production software?

Key findings

  • The proposed contract-based approach successfully prevents atomicity violations by ensuring correlated method calls are executed within a single atomic scope.
  • The static analysis correctly identified a critical atomicity violation in Apache Tomcat 6.0, which was immediately acknowledged and fixed by the development team.
  • The method achieves high precision in detecting atomicity violations, minimizing false positives through filtering of broad control-flow patterns.
  • The prototype demonstrated efficient performance on real-world software, confirming the scalability of the approach.
  • The results show that contracts for concurrency, combined with static verification, significantly improve the reliability of concurrent programs.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.