skip to main content
10.1145/2737924.2738005acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

A formal C memory model supporting integer-pointer casts

Published:03 June 2015Publication History

ABSTRACT

The ISO C standard does not specify the semantics of many valid programs that use non-portable idioms such as integer-pointer casts. Recent efforts at formal definitions and verified implementation of the C language inherit this feature. By adopting high-level abstract memory models, they validate common optimizations. On the other hand, this prevents reasoning about much low-level code relying on the behavior of common implementations, where formal verification has many applications. We present the first formal memory model that allows many common optimizations and fully supports operations on the representation of pointers. All arithmetic operations are well-defined for pointers that have been cast to integers. Crucially, our model is also simple to understand and program with. All our results are fully formalized in Coq.

References

  1. F. Besson, S. Blazy, and P. Wilke. A precise and abstract memory model for C using symbolic values. In APLAS, 2014.Google ScholarGoogle ScholarCross RefCross Ref
  2. C. Ellison and G. Rosu. An executable formal semantics of C with applications. In POPL, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. D. Greenaway, J. Lim, J. Andronick, and G. Klein. Don’t sweat the small stuff: Formal verification of C code without the pain. In PLDI, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. C.-K. Hur, D. Dreyer, G. Neis, and V. Vafeiadis. The marriage of bisimulations and Kripke logical relations. In POPL, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. ISO. ISO/IEC 9899:2011 Information technology – Programming languages – C. 2011.Google ScholarGoogle Scholar
  6. R. Krebbers. Aliasing restrictions of C11 formalized in Coq. In CPP, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. R. Krebbers, X. Leroy, and F. Wiedijk. Formal C semantics: CompCert and the C standard. In ITP, 2014.Google ScholarGoogle ScholarCross RefCross Ref
  8. R. Krebbers and F. Wiedijk. A formalization of the C99 standard in HOL, Isabelle and Coq. In CICM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. X. Leroy. A formally verified compiler back-end. Journal of Automated Reasoning, 43(4):363–446, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. X. Leroy, A. W. Appel, S. Blazy, and G. Stewart. The CompCert memory model, version 2. Research report RR-7987, INRIA, June 2012.Google ScholarGoogle Scholar
  11. M. Norrish. C formalised in HOL. Computer Laboratory Technical Report 453, University of Cambridge, Nov. 1998.Google ScholarGoogle Scholar
  12. J. ˇSevˇc´ık, V. Vafeiadis, F. Zappa Nardelli, S. Jagannathan, and P. Sewell. CompCertTSO: A verified compiler for relaxed-memory concurrency. Journal of the ACM, 60(3):22, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. X. Wang, N. Zeldovich, M. F. Kaashoek, and A. Solar-Lezama. Towards optimization-safe systems: Analyzing the impact of undefined behavior. In SOSP, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. X. Yang, Y. Chen, E. Eide, and J. Regehr. Finding and understanding bugs in C compilers. In PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Zhao, S. Nagarakatte, M. M. Martin, and S. Zdancewic. Formalizing the LLVM intermediate representation for verified program transformations. In POPL, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Zhao, S. Nagarakatte, M. M. Martin, and S. Zdancewic. Formal verification of SSA-based optimizations for LLVM. In PLDI, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A formal C memory model supporting integer-pointer casts

                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
                  PLDI '15: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation
                  June 2015
                  630 pages
                  ISBN:9781450334686
                  DOI:10.1145/2737924
                  • cover image ACM SIGPLAN Notices
                    ACM SIGPLAN Notices  Volume 50, Issue 6
                    PLDI '15
                    June 2015
                    630 pages
                    ISSN:0362-1340
                    EISSN:1558-1160
                    DOI:10.1145/2813885
                    • Editor:
                    • Andy Gill
                    Issue’s Table of Contents

                  Copyright © 2015 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 the author(s) 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: 3 June 2015

                  Permissions

                  Request permissions about this article.

                  Request Permissions

                  Check for updates

                  Qualifiers

                  • research-article

                  Acceptance Rates

                  Overall Acceptance Rate406of2,067submissions,20%

                  Upcoming Conference

                  PLDI '24

                PDF Format

                View or Download as a PDF file.

                PDF

                eReader

                View online with eReader.

                eReader