TL;DR
This paper extends Maximal Causality Reduction (MCR), a powerful technique for verifying concurrent programs under Sequential Consistency (SC), to handle relaxed memory models like Total Store Order (TSO) and Partial Store Order (PSO). By adapting MCR's core logic to account for instruction reordering and developing novel replay mechanisms, the authors achieve significantly more efficient state-space exploration and bug finding for TSO/PSO programs compared to existing methods.
What Problem Does This Paper Address?
Verifying concurrent programs is notoriously difficult due to the exponential explosion of possible thread interleavings. This problem is significantly amplified by relaxed memory models like TSO and PSO, which allow instructions within the same thread to be reordered, further increasing the interleaving space. While previous work on Maximal Causality Reduction (MCR) showed great promise for SC by minimizing redundant state exploration, it was limited to SC and couldn't handle the reordering inherent in TSO and PSO. This paper tackles the challenge of extending MCR to effectively verify programs under these more complex and realistic memory models, aiming to find bugs that are missed by SC-only verification.
Methods
The core of this work lies in two key technical innovations:
- Soundly Encoding TSO/PSO Semantics: The authors adapt MCR's constraint-based approach by relaxing the "must-happen-before" (MHB) constraints. They decompose the MHB constraints into two parts:
Φmem(capturing memory model reordering semantics) andΦsync(capturing synchronization constraints). For TSO and PSO,Φmemis modified to allow reads and writes to be reordered, respecting the semantics of store buffers. This is achieved by using first-order logical constraints and solving them with an SMT solver to generate valid interleavings that can reach new states. - Deterministic Replay for TSO/PSO: A novel replay algorithm is developed to deterministically execute programs according to the generated TSO and PSO interleavings. This algorithm handles instruction reordering by intelligently managing thread-local store buffers. It decides when to buffer a write and when to flush it to main memory by comparing the memory location of the current operation with that specified in the generated interleaving. This ensures that the replayed execution precisely follows the intended, potentially reordered, sequence of operations.
Datasets
The paper evaluates its approach on a collection of popular benchmarks and real applications. These include:
- Classic mutual exclusion algorithms: Dekker, Lamport, Bakery, Peterson.
- Racy programs: StackUnsafe, RVExample.
- A real PSO bug example: From Figure 1 of the paper.
- Other benchmarks: Account, Airline, Allocation, PingPong, StringBuf, Weblech.
The authors note that for comparison with DPOR, they transformed seven standard benchmarks from Java to C/C++ or vice-versa.
Key Insights and Ideas
- Relaxed Memory Models Explode State Space: The paper vividly illustrates how TSO and PSO dramatically increase the number of possible interleavings compared to SC (e.g., 300,000x for a simple case). This highlights why SC-only verification is insufficient for finding many real-world bugs.
- MCR's Power Extends Beyond SC: The core insight is that MCR's principle of maximizing causality reduction can be adapted to relaxed memory models. The key is to correctly model the reordering semantics and develop appropriate replay mechanisms.
- Store Buffers are Crucial for Replay: The deterministic replay algorithm's success hinges on accurately simulating and managing thread-local store buffers, which are central to how TSO and PSO reorder operations.
- "Tricky" Bugs Emerge Under Relaxed Models: The paper demonstrates that bugs that are elusive or non-existent under SC can become apparent and triggerable under TSO/PSO, often due to subtle reordering effects.
Key Results
The paper presents compelling experimental results demonstrating the effectiveness of their extended MCR approach:
- State-Space Exploration: On average, their approach explores 5-10X fewer executions than DPOR for TSO and PSO. For specific benchmarks like RVExample, it takes significantly fewer executions (57 vs. ~2000 for DPOR under SC).
- Bug Finding: The approach is highly effective at finding bugs. It typically takes only a few executions to reveal known errors, whereas DPOR and SATCheck either take significantly more executions or fail to find the bugs altogether (sometimes due to exceptions or timeouts). For the PSO bug in Figure 1, their approach found it in just three runs.
- Scalability: The approach scales well to real-world applications, with MCR exploring the state-space of programs like Weblech (35K LOC) in a reasonable number of executions.
- Comparison: Compared to DPOR, their MCR extension shows significant improvements in both state-space exploration and bug finding for TSO and PSO. SATCheck, while effective for SC and TSO, is noted to miss states and has implementation challenges for complex benchmarks.
Limitations and Future Work
- Optimality: The authors acknowledge that their approach, while significantly improving upon existing methods, is not strictly optimal for minimizing redundancy under TSO and PSO, unlike the original MCR for SC. This is because distinct seed interleavings might still lead to the same state due to the nature of relaxed memory models.
- Merging Redundant Interleavings: They suggest that a potential way to eliminate some redundancy for TSO and PSO would be to merge multiple independent seed interleavings into a single one, especially when they are non-overlapping and permutable.
- Future Work: The paper implies that further research into optimizing the redundancy reduction for TSO/PSO, potentially through merging interleavings, would be beneficial. They also mention that their approach is primarily for Java and that adapting it to other languages or hardware architectures might be an area for future exploration.
Summary updated