Abstract
Regression verification is the problem of deciding whether two similar programs are equivalent under an arbitrary yet equal context, given some definition of equivalence. So far this problem has only been studied for the case of single-threaded deterministic programs. We present a method for regression verification of multi-threaded programs. Specifically, we develop a proof-rule whose premise requires only to verify equivalence between sequential functions, whereas their consequents are equivalence of concurrent programs. This ability to avoid composing threads altogether when discharging premises, in a fully automatic way and for general programs, uniquely distinguishes our proof rule from others used for classical verification of concurrent programs. We also consider the effect of dynamic thread creation and synchronization primitives.
Similar content being viewed by others
Notes
An indication of the difficulty of this problem is given by Lee’s statement in [14], that “with threads, there is no useful theory of equivalence”.
This is a simplification of the POSIX pthread_create command, which enables in addition to send various thread attributes.
A different interpretation is that context switches are allowed, as long as the control is transferred to threads that do not access variables that are accessed in statement. The method described here works in both cases.
Verification systems such as CBMC [3] support assume statements with which such constraints can be added.
References
Chaki S, Gurfinkel A, Strichman O (2011) Time-bounded analysis of real-time systems. In: FMCAD’11
Chaki S, Gurfinkel A, Strichman O (2012) Regression verification for multi-threaded programs. In: Kuncak V, Rybalchenko A (eds) VMCAI, vol 7148 of Lecture Notes in computer science, Springer, pp 119–135
Clarke EM, Kroening D, Lerda F (2004) A tool for checking ANSI-C programs. In: TACAS, pp 168–176
Cobleigh JM, Giannakopoulou D, Pasareanu CS (2003) Learning assumptions for compositional verification. In: 9th International conference on tools and algorithms for the construction and analysis of systems (TACAS’03), pp 331–346
de Moura L, Bjorner N (2008) Z3: an efficient smt solver. In: International conference on tools and algorithms for the construction and analysis of systems (TACAS)
Felsing D, Grebing S, Klebanov V, Rmmer P, Ulbrich M (2014) Automating regression verification. In: Automated software engineering (ASE), (to be published)
Godlin B (2008) Regression verification: theoretical and implementation aspects. Master’s thesis, Technion, Israel Institute of Technology
Godlin B, Strichman O (2008) Inference rules for proving the equivalence of recursive procedures. Acta Inform 45(6):403–439
Godlin B, Strichman O (2009) Regression verification. In: \(46^{th}\) Design automation conference (DAC)
Gupta A, Popeea C, Rybalchenko A (2011) Threader: a constraint-based verifier for multi-threaded programs. In: CAV, pp 412–417
Jones CB (1983) Tentative steps toward a development method for interfering programs. ACM Trans Program Lang Syst 5(4):596–619
Kaser O, Ramakrishnan CR, Pawagi S (1993) On the conversion of indirect to direct recursion. LOPLAS 2(1–4):151–164
Kawaguchi M, Lahiri SK, Rebelo H (2010) Conditional equivalence. Technical Report MSR-TR-2010-119, Microsoft Research
Lee EA (2006) The problem with threads. IEEE. Computer 39(5):33–42
Owicki S, Gries D (1976) An axiomatic proof technique for parallel programs. Acta Inform 6:319–340
Acknowledgments
This material is based upon work funded and supported by the Department of Defense under Contract No. FA8721-05-C-0003 with Carnegie Mellon University for the operation of the Software Engineering Institute, a federally funded research and development center. This material has been approved for public release and unlimited distribution. DM-0001970.
Author information
Authors and Affiliations
Corresponding author
Appendix 1: k-equivalence of MT programs
Appendix 1: k-equivalence of MT programs
The following is a bounded version of the partial equivalence problem for MT programs, i.e., when loops and recursion are bounded. Denote by \(P^k\) the program P after all loops are unrolled k times and all recursive calls are unrolled to depth k. In \(P^k\), traces that satisfy the loop guard at the last iteration, or reach a recursive call at depth \(k+1\), are blocked.Footnote 4 Let R(k) denote the I/O relation of \(P^k\). Then:
Definition 10
(k-Equivalence of nondeterministic programs) Two nondeterministic programs P, \(P'\) are k-equivalent if \(R(k) = R'(k)\).
Since nondeterminism can be eliminated by adding inputs, we can assume that the scheduler decisions can be modeled with additional set of input variables that we denote by s. We call a valuation of s a determinization state. Let \(T^k(\overline{in},\overline{s},\overline{out},\overline{v})\) denote the transition relation of \(P^k\), where \(\overline{in}\) is a vector of input variables, \(\overline{s}\) is a vector of determinization variables, \(\overline{out}\) is a vector of output variables and \(\overline{v}\) is a vector of other variables. k-equivalence of P and \(P'\) can be established by validating:
and
As a small experiment, we verified the equivalence of two versions of an MT program based on this formula. Our program had four threads that read and wrote to shared variables, without loops and recursion. We sequentialized the two versions via our tool rek [1], which introduces determinization variables. We then used CBMC to convert the resulting programs to SMT-LIB format, and concatenated them. Finally, we added the quantifiers as prescribed by the two equations above, and used Z3 to discharge it. It took Z3 less than 2 s to prove that the two versions are indeed partially equivalent.
Rights and permissions
About this article
Cite this article
Chaki, S., Gurfinkel, A. & Strichman, O. Regression verification for multi-threaded programs (with extensions to locks and dynamic thread creation). Form Methods Syst Des 47, 287–301 (2015). https://doi.org/10.1007/s10703-015-0237-0
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10703-015-0237-0