skip to main content
10.1145/3381898.3397211acmconferencesArticle/Chapter ViewAbstractPublication PagesismmConference Proceedingsconference-collections
research-article

Verified sequential Malloc/Free

Published:16 June 2020Publication History

ABSTRACT

We verify the functional correctness of an array-of-bins (segregated free-lists) single-thread malloc/free system with respect to a correctness specification written in separation logic. The memory allocator is written in standard C code compatible with the standard API; the specification is in the Verifiable C program logic, and the proof is done in the Verified Software Toolchain within the Coq proof assistant. Our "resource-aware" specification can guarantee when malloc will successfully return a block, unlike the standard Posix specification that allows malloc to return NULL whenever it wants to. We also prove subsumption (refinement): the resource-aware specification implies a resource-oblivious spec.

References

  1. David Aspinall and Adriana B. Compagnoni. 2003.Google ScholarGoogle Scholar
  2. Heap-Bounded Assembly Language. J. Autom. Reasoning 31, 3-4 (2003), 261–302.Google ScholarGoogle Scholar
  3. Gilles Barthe, Mariela Pavlova, and Gerardo Schneider. 2005. Precise analysis of memory consumption using program logics. In Third IEEE International Conference on Software Engineering and Formal Methods (SEFM’05). IEEE, 86–95.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Lennart Beringer and Andrew W. Appel. 2019. Abstraction and Subsumption in Modular Verification of C Programs. In Formal Methods - The Next 30 Years - Third World Congress, FM 2019, Proceedings (LNCS), Maurice H. ter Beek, Annabelle McIver, and José N. Oliveira (Eds.), Vol. 11800. Springer, 573–590. 030-30942-8_34 Google ScholarGoogle ScholarCross RefCross Ref
  5. Lennart Beringer, Martin Hofmann, Alberto Momigliano, and Olha Shkaravska. 2004. Automatic Certification of Heap Consumption. In LPAR’04: Logic for Programming, Artificial Intelligence, and Reasoning, 11th International Conference, Proceedings (LNCS), Franz Baader and Andrei Voronkov (Eds.), Vol. 3452. Springer, 347–362. 10.1007/978-3-540-32275-7_23 Google ScholarGoogle ScholarCross RefCross Ref
  6. Lennart Beringer, Adam Petcher, Katherine Q. Ye, and Andrew W. Appel. 2015. Verified Correctness and Security of OpenSSL HMAC. In 24th USENIX Security Symposium. USENIX Assocation, 207–221.Google ScholarGoogle Scholar
  7. Lars Birkedal, Noah Torp-Smith, and John C Reynolds. 2004.Google ScholarGoogle Scholar
  8. Local reasoning about a copying garbage collector. In Proceedings of the 31st ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 220–231.Google ScholarGoogle Scholar
  9. Qinxiang Cao, Lennart Beringer, Samuel Gruetter, Josiah Dodds, and Andrew W. Appel. 2018. VST-Floyd: A Separation Logic Tool to Verify Correctness of C Programs. J. Autom. Reason. 61, 1-4 (June 2018), 367–422. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Santiago Cuellar, Nick Giannarakis, Jean-Marie Madiot, William Mansky, Lennart Beringer, Qinxiang Cao, and Andrew W. Appel. 2020.Google ScholarGoogle Scholar
  11. Hoang-Hai Dang, Jacques-Henri Jourdan, Jan-Oliver Kaiser, and Derek Dreyer. 2019. RustBelt meets relaxed memory. Proceedings of the ACM on Programming Languages 4, POPL (2019), 1–29.Google ScholarGoogle Scholar
  12. Yi Feng and Emery D. Berger. 2005. A Locality-Improving Dynamic Memory Allocator. In 2005 Workshop on Memory System Performance. 68–77. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Peter Gammie, Antony L Hosking, and Kai Engelhardt. 2015. Relaxing safely: verified on-the-fly garbage collection for x86-TSO. ACM SIGPLAN Notices 50, 6 (2015), 99–109.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Ronghui Gu, Jérémie Koenig, Tahina Ramananandro, Zhong Shao, Xiongnan (Newman) Wu, Shu-Chun Weng, Haozhong Zhang, and Yu Guo. 2015. Deep Specifications and Certified Abstraction Layers. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Sriram K. Rajamani and David Walker (Eds.). ACM, 595–608. 2676726.2676975 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Ronghui Gu, Zhong Shao, Hao Chen, Jieung Kim, Jérémie Koenig, Xiongnan (Newman) Wu, Vilhelm Sjöberg, and David Costanzo. 2019.Google ScholarGoogle Scholar
  16. Building certified concurrent OS kernels. Commun. ACM 62, 10 (2019), 89–99. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Martin Hofmann and Steffen Jost. 2003. Static prediction of heap space usage for first-order functional programs. In POPL ’03: 30th ACM Symp. on Principles of Programming Languages. 185–197.Google ScholarGoogle Scholar
  18. Bart Jacobs, Jan Smans, Pieter Philippaerts, Frédéric Vogels, Willem Penninckx, and Frank Piessens. 2011.Google ScholarGoogle Scholar
  19. VeriFast: A powerful, sound, predictable, fast verifier for C and Java. In NASA Formal Methods Symposium. Springer, 41–55.Google ScholarGoogle Scholar
  20. Ke Jiang, David Sanan, Yongwang Zhao, Shuanglong Kan, and Yang Liu. 2019. A Formally Verified Buddy Memory Allocation Model. In 2019 24th International Conference on Engineering of Complex Computer Systems (ICECCS). IEEE, 144–153.Google ScholarGoogle ScholarCross RefCross Ref
  21. Jeehoon Kang, Chung-Kil Hur, William Mansky, Dmitri Garbuzov, Steve Zdancewic, and Viktor Vafeiadis. 2015.Google ScholarGoogle Scholar
  22. A Formal C Memory Model Supporting Integer-Pointer Casts. In PLDI’15: 36th annual ACM SIGPLAN conference on Programming Languages Design and Implementation. 326–335.Google ScholarGoogle Scholar
  23. Florent Kirchner, Nikolai Kosmatov, Virgile Prevosto, Julien Signoles, and Boris Yakobowski. 2015. Frama-C: A software analysis perspective. Formal Aspects of Computing 27, 3 (01 May 2015), 573–609. Google ScholarGoogle ScholarCross RefCross Ref
  24. Gerwin Klein, Kevin Elphinstone, Gernot Heiser, June Andronick, David Cock, Philip Derrin, Dhammika Elkaduwe, Kai Engelhardt, Rafal Kolanski, Michael Norrish, et al. 2009.Google ScholarGoogle Scholar
  25. seL4: Formal verification of an OS kernel. In Proceedings of the ACM SIGOPS 22nd symposium on Operating systems principles. ACM, 207–220.Google ScholarGoogle Scholar
  26. Donald E. Knuth. 1973.Google ScholarGoogle Scholar
  27. The Art of Computer Programming, Vol. I: Fundamental Algorithms (second edition). Addison Wesley, Reading, MA.Google ScholarGoogle Scholar
  28. Daan Leijen, Benjamin Zorn, and Leonardo de Moura. 2019. Mimalloc: Free List Sharding in Action. In Asian Symposium on Programming Languages and Systems. Springer, 244–265.Google ScholarGoogle Scholar
  29. Xavier Leroy. 2009. Formal verification of a realistic compiler. Commun. ACM 52, 7 (2009), 107–115.Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Paul Liétar, Theodore Butler, Sylvan Clebsch, Sophia Drossopoulou, Juliana Franco, Matthew J. Parkinson, Alex Shamis, Christoph M. Wintersteiger, and David Chisnall. 2019.Google ScholarGoogle Scholar
  31. snmalloc: a message passing allocator. In Proceedings of the 2019 ACM SIGPLAN International Symposium on Memory Management (ISMM). 122–135.Google ScholarGoogle Scholar
  32. William Mansky, Andrew W. Appel, and Aleksey Nogin. 2017.Google ScholarGoogle Scholar
  33. A Verified Messaging System. In Proceedings of the 2017 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’17). ACM.Google ScholarGoogle Scholar
  34. William Mansky, Wolf Honoré, and Andrew W. Appel. 2020. Connecting Higher-Order Separation Logic to a First-Order Outside World. In ESOP’20: European Symposium on Programming.Google ScholarGoogle Scholar
  35. Nicolas Marti, Reynald Affeldt, and Akinori Yonezawa. 2006. Formal Verification of the Heap Manager of an Operating System using Separation Logic. In SPACE 06: Third workshop on Semantics, Program Analysis, and Computing Environments for Memory Management.Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Andrew McCreight, Tim Chevalier, and Andrew Tolmach. 2010.Google ScholarGoogle Scholar
  37. A certified framework for compiling and executing garbage-collected languages. In ICFP’10: 15th ACM SIGPLAN International Conference on Functional programming. 273–284.Google ScholarGoogle Scholar
  38. Andrew McCreight, Zhong Shao, Chunxiao Lin, and Long Li. 2007. A general framework for certifying garbage collectors and their mutators. In PLDI’07: 28th ACM SIGPLAN Conference on Programming Language Design and Implementation. 468–479.Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Peter O’Hearn, John Reynolds, and Hongseok Yang. 2001. Local Reasoning about Programs that Alter Data Structures. In CSL’01: Annual Conference of the European Association for Computer Science Logic. 1–19. LNCS 2142.Google ScholarGoogle ScholarCross RefCross Ref
  40. Matthew J. Parkinson and Gavin M. Bierman. 2005.Google ScholarGoogle Scholar
  41. Separation logic and abstraction. In 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2005). 247–258. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. J. M. Robson. 1971. An Estimate of the Store Size Necessary for Dynamic Storage Allocation. J. Association for Computing Machinery 18, ISMM ’20, June 16, 2020, London, UK Andrew W. Appel and David A. Naumann 3 (July 1971), 416–423.Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Harvey Tuch. 2009. Formal verification of C systems code. Journal of Automated Reasoning 42, 2-4 (2009), 125–187.Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Gijs Vanspauwen and Bart Jacobs. 2017.Google ScholarGoogle Scholar
  45. Verifying cryptographic protocol implementations that use industrial cryptographic APIs. CW Reports (2017).Google ScholarGoogle Scholar
  46. Shengyi Wang, Qinxiang Cao, Anshuman Mohan, and Aquinas Hobor. 2019. Certifying Graph-Manipulating C Programs via Localizations within Data Structures. In Proceedings of the ACM on Programming Languages (OOPSLA).Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Xi Wang, Nickolai Zeldovich, M Frans Kaashoek, and Armando Solar-Lezama. 2013. Towards optimization-safe systems: analyzing the impact of undefined behavior. In Proceedings 24th ACM Symposium on Operating Systems Principles. ACM, 260–275.Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Charles B. Weinstock. 1976.Google ScholarGoogle Scholar
  49. Dynamic storage allocation techniques. Ph.D. Dissertation. Carnegie Mellon University.Google ScholarGoogle Scholar
  50. John Wickerson, Mike Dodds, and Matthew J. Parkinson. 2010.Google ScholarGoogle Scholar
  51. Explicit Stabilisation for Modular Rely-Guarantee Reasoning. In European Symposium on Programming (ESOP). 610–629.Google ScholarGoogle Scholar
  52. Katherine Q. Ye, Matthew Green, Naphat Sanguansin, Lennart Beringer, Adam Petcher, and Andrew W. Appel. 2017. Verified Correctness and Security of mbedTLS HMAC-DRBG. In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security (CCS’17). ACM.Google ScholarGoogle Scholar
  53. Arseniy Zaostrovnykh, Solal Pirelli, Luis Pedrosa, Katerina Argyraki, and George Candea. 2017. A Formally Verified NAT. In SIGCOMM’17: Proceedings of the conference of the ACM Special Interest Group on Data Communication. 141–154.Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Yu Zhang, Yongwang Zhao, David Sanan, Lei Qiao, and Jinkun Zhang. 2019. A Verified Specification of TLSF Memory Management Allocator Using State Monads. In Dependable Software Engineering. Theories, Tools, and Applications, Nan Guan, Joost-Pieter Katoen, and Jun Sun (Eds.). Springer International Publishing, 122–138. Abstract 1 Introduction 2 The Algorithm and Data Structure 3 Specification in Separation Logic 4 Resource Tracking 5 Filling the Resource Vector 6 Funspec Subsumption 7 Formal Guarantees w.r.t. C Standard 8 Bugs 9 Verification Effort 10 Future Work 11 Conclusion Acknowledgments ReferencesGoogle ScholarGoogle Scholar

Index Terms

  1. Verified sequential Malloc/Free

        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
        • Published in

          cover image ACM Conferences
          ISMM 2020: Proceedings of the 2020 ACM SIGPLAN International Symposium on Memory Management
          June 2020
          114 pages
          ISBN:9781450375665
          DOI:10.1145/3381898

          Copyright © 2020 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: 16 June 2020

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article

          Acceptance Rates

          Overall Acceptance Rate72of156submissions,46%

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader