skip to main content
research-article

Compositional Shape Analysis by Means of Bi-Abduction

Published:01 December 2011Publication History
Skip Abstract Section

Abstract

The accurate and efficient treatment of mutable data structures is one of the outstanding problem areas in automatic program verification and analysis. Shape analysis is a form of program analysis that attempts to infer descriptions of the data structures in a program, and to prove that these structures are not misused or corrupted. It is one of the more challenging and expensive forms of program analysis, due to the complexity of aliasing and the need to look arbitrarily deeply into the program heap. This article describes a method of boosting shape analyses by defining a compositional method, where each procedure is analyzed independently of its callers. The analysis algorithm uses a restricted fragment of separation logic, and assigns a collection of Hoare triples to each procedure; the triples provide an over-approximation of data structure usage. Our method brings the usual benefits of compositionality---increased potential to scale, ability to deal with incomplete programs, graceful way to deal with imprecision---to shape analysis, for the first time.

The analysis rests on a generalized form of abduction (inference of explanatory hypotheses), which we call bi-abduction. Bi-abduction displays abduction as a kind of inverse to the frame problem: it jointly infers anti-frames (missing portions of state) and frames (portions of state not touched by an operation), and is the basis of a new analysis algorithm. We have implemented our analysis and we report case studies on smaller programs to evaluate the quality of discovered specifications, and larger code bases (e.g., sendmail, an imap server, a Linux distribution) to illustrate the level of automation and scalability that we obtain from our compositional method.

This article makes number of specific technical contributions on proof procedures and analysis algorithms, but in a sense its more important contribution is holistic: the explanation and demonstration of how a massive increase in automation is possible using abductive inference.

References

  1. Abdulla, P. A., Bouajjani, A., Cederberg, J., Haziza, F., and Rezine, A. 2008. Monotonic abstraction for programs with dynamic memory heaps. In Proceedings of the 20th International Conference on Computer Aided Verification, 20th International Conference (CAV). 341--354. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Balaban, I., Pnueli, A., and Zuck, L. D. 2005. Shape analysis by predicate abstraction. In Proceedings of the 6th International Conference on Verification, Model Checking, and Abstract Interpretation (VMCAI). Lecture Notes in Computer Science, , vol. 3385. Springer, 164--180. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Ball, T., Bounimova, E., Cook, B., Levin, V., Lichtenberg, J., McGarvey, C., Ondrusek, B., Rajamani, S. K., and Ustuner, A. 2006. Thorough static analysis of device drivers. In Proceedings of the EuroSys Conference. 73--85. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Berdine, J., Calcagno, C., and O’Hearn, P. W. 2004. A decidable fragment of separation logic. In Proceedings of the 24th International Conference on Foundations of Software Technology and Theoretical Computer Science. Vol. 3328. 97--109. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Berdine, J., Calcagno, C., Cook, B., Distefano, D., O’Hearn, P., Wies, T., and Yang, H. 2007. Shape analysis of composite data structures. In Proceedings of the 19th International Conference on Computer Aided Verification (CAV). 178--192. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Berdine, J., Calcagno, C., and O’Hearn, P. W. 2005a. Smallfoot: Automatic modular assertion checking with separation logic. In Proceedings of the 4th International Symposium on Formal Methods for Components and Objects. Lecture Notes in Computer Science, vol. 4111. 115--137. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Berdine, J., Calcagno, C., and O’Hearn, P. W. 2005b. Symbolic execution with separation logic. In Proceedings of the 3rd Asian Symposium on Programming Languages and Systems (APLAS). 52--68. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Bierhoff, K. and Aldrich, J. 2005. Lightweight object specification with typestates. In Proceedings of the 13th ACM SIGSOFT Symposium on Foundations of Software Engineering (FSE). 217--226. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Bouajjani, A., Habermehl, P., Moro, P., and Vojnar, T. 2005. Verifying programs with dynamic 1-selector-linked structures in regular model checking. In Proceedings of the 11th Conference on Tools and Algorithms for the Construction and Analysis of Systems (TACAS). 13--29. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Bouajjani, A., Habermehl, P., Rogalewicz, A., and Vojnar, T. 2006. Abstract tree regular model checking of complex dynamic data structures. In Proceedings of the 13th International Symposium on Static Analysis (SAS). Lecture Notes in Computer Science, vol. 4134. 52--70. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Calcagno, C., Distefano, D., O’Hearn, P. W., and Yang, H. 2006. Beyond reachability: Shape abstraction in the presence of pointer arithmetic. In Proceedings of the 13th International Symposium on Static Analysis (SAS). Lecture Notes in Computer Science, vol. 4134. 182--203. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Calcagno, C., Distefano, D., O’Hearn, P., and Yang, H. 2007a. Footprint analysis: A shape analysis that discovers preconditions. In Proceedings of the 14th International Symposium on Static Analysis (SAS). Lecture Notes in Computer Science, vol. 4634. 402--418. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Calcagno, C., O’Hearn, P., and Yang, H. 2007b. Local action and abstract separation logic. In Proceedings of the 22nd IEEE Symposium on Logic in Computer Science (LICS). 366--378. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Calcagno, C., Distefano, D., O’Hearn, P., and Yang, H. 2009a. Compositional shape analysis by means of bi-abduction. In Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). 289--300. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Calcagno, C., Distefano, D., and Vafeiadis, V. 2009b. Bi-abductive resource invariant synthesis. In Proceedings of the 7th Asian Symposium on Programming Languages and Systems (APLAS). 259--274. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Chang, B. and Rival, X. 2008. Relational inductive shape analysis. In Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). 247--260. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Chang, B., Rival, X., and Necula, G. 2007. Shape analysis with structural invariant checkers. In Proceedings of the 14th International Symposium on Static Analysis (SAS). Lecture Notes in Computer Science, Springer. 384--401. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Cook, S. A. 1978. Soundness and completeness of an axiomatic system for program verification. SIAM J. Comput. 7, 70--90.Google ScholarGoogle ScholarCross RefCross Ref
  19. Cousot, P. and Cousot, R. 1977. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proceedings of the 4th ACM Symposium on Principles of Programming Languages (POPL). 238--252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Cousot, P. and Cousot, R. 2001. Compositional separate modular static analysis of programs by abstract interpretation. In Proceedings of SSGRR.Google ScholarGoogle Scholar
  21. Cousot, P. and Cousot, R. 2002. Modular static program analysis. In Proceedings of the 11th International Conference on Compiler Construction (CC). Lecture Notes in Computer Science, vol. 2304. 159--178. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Cousot, P., Cousot, R., Feret, J., Mauborgne, L., Miné, A., Monniaux, D., and Rival, X. 2005. The ASTRÉE analyzer. In Proceedings of the 14th European Symposium on Programming (ESOP). Lecture Notes in Computer Science, vol. 3444. 21--30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Creignou, N. and Zanuttini, B. 2006. A complete classification of the complexity of propositional abduction. SIAM J. Comput. 36, 1, 207--229. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. DeLine, R. and Fähndrich, M. 2004. Typestates for objects. In Proceedings of the 18th European Conference on Object-Oriented Programming (ECOOP). 465--490.Google ScholarGoogle Scholar
  25. Distefano, D. and Filipovic, I. 2010. Memory leaks detection in java by bi-abductive inference. In Proceedings of the 13th International Conference on Fundamental Approaches to Software Engineering (FASE). Lecture Notes in Computer Science, vol. 6013. 278--292. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Distefano, D. and Parkinson, M. 2008. jStar: Towards Practical Verification for Java. In Proceedings of the 23rd Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). 213--226. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Distefano, D., O’Hearn, P., and Yang, H. 2006. A local shape analysis based on separation logic. In Proceedings of the 12th Conference on Tools and Algorithms for the Construction and Analysis of Systems (TACAS). 287--302. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Dor, N., Rodeh, M., and Sagiv, M. 2003. CSSV: Towards a realistic tool for statically detecting all buffer overflows in C. In Proceedings of the ACM SIGPLAN 2003 Conference on Programming Language Design and Implementation (PLDI). 155--167. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Eiter, T. and Gottlob, G. 1995. The complexity of logic-based abduction. J. ACM 42, 1, 3--42. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Eiter, T. and Makino, K. 2002. On computing all abductive explanations. In Proceedings of the 18th National Conference on Artificial Intelligence and 14th Conference on Innovative Applications of Artificial Intelligence (AAAI/IAAI). 62--67. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Ghiya, R. and Hendren, L. 1996. Is it a tree, a DAG, or a cyclic graph? A shape analysis for heap-directed pointers in C. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). 1--15. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Giacobazzi, R. 1994. Abductive analysis of modular logic programs. In Proceedings of the International Logic Programming Symposium. The MIT Press, 377--392. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Gopan, D. and Reps, T. 2007. Low-level library analysis and summarization. In Proceedings of the 9th International Conference on Computer Aided Verification (CAV). 68--81. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Gotsman, A., Berdine, J., and Cook, B. 2006. Interprocedural shape analysis with separated heap abstractions. In Proceedings of the 13th International Symposium on Static Analysis (SAS). Lecture Notes in Computer Science, vol. 4134. 240--260. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Gulavani, B. S., Chakraborty, S., Ramalingam, G., and Nori, A. V. 2009. Bottom-up shape analysis. In Proceedings of the 16th International Symposium on Static Analysis (SAS). 188--204. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Gulwani, S. and Tiwari, A. 2007. Computing procedure summaries for interprocedural analysis. In Proceedings of the 16th European Symposium on Programming (ESOP). Lecture Notes in Computer Science, vol. 4421. Springer, 253--267. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Gulwani, S., McCloskey, B., and Tiwari, A. 2008. Lifting abstract interpreters to quantified logical domains. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). 235--246. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Guo, B., Vachharajani, N., and August, D. 2007. Shape analysis with inductive recursion synthesis. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Hackett, B. and Rugina, R. 2005. Region-based shape analysis with tracked locations. In Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languagesc (POPL). ACM, 310--323. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Henzinger, T., Jhala, R., Majumdar, R., and Sutre, G. 2002. Lazy abstraction. In Proceedings of the 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, 58--70. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Hoare, C. A. R. 1971. Procedures and parameters: An axiomatic approach. In Proceedings of the Symposium on the Semantics of Algebraic Languages. Lecture Notes in Math, vol. 188. 102--116.Google ScholarGoogle ScholarCross RefCross Ref
  42. Ishtiaq, S. and O’Hearn, P. W. 2001. BI as an assertion language for mutable data structures. In Proceedings of the 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, 14--26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Jhala, R. and Majumdar, R. 2009. Software model checking. ACM Comput. Surv. 41, 4. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Jung, Y. and Yi, K. 2008. Practical memory leak detector based on parameterized procedural summaries. In Proceedings of the 7th International Symposium on Memory Management. 131--140. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Kakas, A. C., Kowalski, R. A., and Toni, F. 1992. Abductive logic programming. J. Logic Comput. 2, 6, 719--770.Google ScholarGoogle ScholarCross RefCross Ref
  46. Kleymann, T. 1999. Hoare logic and auxiliary variables. Form. Asp. Comput. 11, 5, 541--566.Google ScholarGoogle ScholarCross RefCross Ref
  47. Lev-Ami, T., Immerman, N., and Sagiv, M. 2006. Abstraction for shape analysis with fast and precise transfomers. In Proceedings of the 18th International Conference on Computer Aided Verification (CAV). Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Lev-Ami, T., Sagiv, M., Reps, T., and Gulwani, S. 2007. Backward analysis for inferring quantified preconditions. Tech rep. TR-2007-12-01, Tel-Aviv University.Google ScholarGoogle Scholar
  49. Luo, C., Craciun, F., Qin, S., He, G., and Chin, W.-N. 2010. Verifying pointer safety for programs with unknown calls. J. Symb. Comput. 45, 11, 1163--1183. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Magill, S., Berdine, J., Clarke, E., and Cook, B. 2007. Arithmetic strengthening for shape analysis. In Proceedings of the 14th International Symposium on Static Analysis (SAS). 419--436. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Manevich, R., Yahav, E., Ramalingam, G., and Sagiv, M. 2005. Predicate abstraction and canonical abstraction for singly-linked lists. In Proceedings of the 6th International Conference on Verification, Model Checking, and Abstract Interpretation (VMCA). Lecture Notes in Computer Science, vol. 3385. 181--198. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Manevich, R., Berdine, J., Cook, B., Ramalingam, G., and Sagiv, M. 2007. Shape analysis by graph decomposition. In Proceedings of the 13th Conference on Tools and Algorithms for the Construction and Analysis of Systems (TACAS). Lecture Notes in Computer Science, vol. 4424. Springer, 3--18. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. Marron, M., Hermenegildo, M., Kapur, D., and Stefanovic, D. 2008. Efficient context-sensitive shape analysis with graph based heap models. In Proceedings of the 17th International Conference on Compiler Construction (CC). Lecture Notes in Computer Science, vol 4959. 245--259. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Moy, Y. 2008. Sufficient preconditions for modular assertion checking. In Proceedings of the 9th International Conference on Verification, Model Checking, and Abstract Interpretation (VMCAI). 188--202. Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Naumann, D. A. 2001. Calculating sharp adaptation rules. Inf. Process. Lett. 77, 2-4, 201--208. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Nguyen, H. H. and Chin, W.-N. 2008. Enhancing program verification with lemmas. In Proceedings of the 20th International Conference on Computer Aided Verification (CAV). Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. Nystrom, E., Kim, H., and Hwu, W. 2004. Bottom-up and top-down context-sensitive summary-based pointer analysis. In Proceedings of the 11th International Symposium on Static Analysis (SAS). 165--180.Google ScholarGoogle Scholar
  58. O’Hearn, P. W. 2007. Resources, concurrency and local reasoning. Theoret. Comput. Sci. 75, 1-3, 271--307. Google ScholarGoogle ScholarDigital LibraryDigital Library
  59. O’Hearn, P. W., Reynolds, J. C., and Yang, H. 2001. Local reasoning about programs that alter data structures. In Proceedings of the 15th International Workshop on Computer Science Logic (CSL). 1--19. Google ScholarGoogle ScholarDigital LibraryDigital Library
  60. O’Hearn, P. W., Yang, H., and Reynolds, J. C. 2009. Separation and information hiding. ACM Trans. Program. Lang. Syst. 31, 3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  61. Paul, G. 1993. Approaches to abductive reasoning: an overview. Artif. Intell. Rev. 7, 2, 109--152.Google ScholarGoogle ScholarCross RefCross Ref
  62. Peirce, C. 1958. Collected Papers of Charles Sanders Peirce. Harvard University Press.Google ScholarGoogle Scholar
  63. Podelski, A. and Wies, T. 2005. Boolean heaps. In Proceedings of the 12th International Symposium on Static Analysis (SAS). Lecture Notes in Computer Science, vol. 3672. Springer, 268--283. Google ScholarGoogle ScholarDigital LibraryDigital Library
  64. Podelski, A., Rybalchenko, A., and Wies, T. 2008. Heap assumptions on demand. In Proceedings of the 18th International Conference on Computer Aided Verification (CAV). Google ScholarGoogle ScholarDigital LibraryDigital Library
  65. Pym, D., O’Hearn, P., and Yang, H. 2004. Possible worlds and resources: the semantics of BI. Theoret. Comput. Sci. 315, 1, 257--305. Google ScholarGoogle ScholarDigital LibraryDigital Library
  66. Reps, T., Horwitz, S., and Sagiv, M. 1995. Precise interprocedural dataflow analysis via graph reachability. In Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  67. Reynolds, J. C. 2002. Separation logic: A logic for shared mutable data structures. In Proceedings of the 17th Annual IEEE Symposium on Logic in Computer Science (LICS). 55--74. Google ScholarGoogle ScholarDigital LibraryDigital Library
  68. Rinetzky, N., Bauer, J., Reps, T., Sagiv, M., and Wilhelm, R. 2005a. A semantics for procedure local heaps and its abstractions. In Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  69. Rinetzky, N., Sagiv, M., and Yahav, E. 2005b. Interprocedural shape analysis for cutpoint-free programs. In Proceedings of the 12th International Symposium on Static Analysis (SAS). Lecture Notes in Computer Science, vol. 3672. 284--302. Google ScholarGoogle ScholarDigital LibraryDigital Library
  70. Sagiv, M., Reps, T., and Wilhelm, R. 1998. Solving shape-analysis problems in languages with destructive updating. ACM Trans. Prog. Lang. Syst. 20, 1, 1--50. Google ScholarGoogle ScholarDigital LibraryDigital Library
  71. Sagiv, M., Reps, T., and Wilhelm, R. 2002. Parametric shape analysis via 3-valued logic. ACM Trans. Prog. Lang. Syst. 24, 3, 217--298. Google ScholarGoogle ScholarDigital LibraryDigital Library
  72. Whaley, J. and Rinard, M. 2006. Compositional pointer and escape analysis for Java. In Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). 187--206. Google ScholarGoogle ScholarDigital LibraryDigital Library
  73. Yang, H. 2001. Local reasoning for stateful programs. Ph.D. thesis, University of Illinois, Urbana-Champaign. Google ScholarGoogle ScholarDigital LibraryDigital Library
  74. Yang, H., Lee, O., Berdine, J., Calcagno, C., Cook, B., Distefano, D., and O’Hearn, P. W. 2008. Scalable shape analysis for systems code. In Proceedings of the 20th International Conference on Computer Aided Verification (CAV). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Compositional Shape Analysis by Means of Bi-Abduction

              Recommendations

              Comments

              Login options

              Check if you have access through your login credentials or your institution to get full access on this article.

              Sign in

              Full Access

              • Published in

                cover image Journal of the ACM
                Journal of the ACM  Volume 58, Issue 6
                December 2011
                209 pages
                ISSN:0004-5411
                EISSN:1557-735X
                DOI:10.1145/2049697
                Issue’s Table of Contents

                Copyright © 2011 ACM

                Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 1 December 2011
                • Revised: 1 May 2011
                • Accepted: 1 May 2011
                • Received: 1 August 2010
                Published in jacm Volume 58, Issue 6

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • research-article
                • Research
                • Refereed

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader