skip to main content
research-article

Finding and understanding bugs in C compilers

Published:04 June 2011Publication History
Skip Abstract Section

Abstract

Compilers should be correct. To improve the quality of C compilers, we created Csmith, a randomized test-case generation tool, and spent three years using it to find compiler bugs. During this period we reported more than 325 previously unknown bugs to compiler developers. Every compiler we tested was found to crash and also to silently generate wrong code when presented with valid input. In this paper we present our compiler-testing tool and the results of our bug-hunting study. Our first contribution is to advance the state of the art in compiler testing. Unlike previous tools, Csmith generates programs that cover a large subset of C while avoiding the undefined and unspecified behaviors that would destroy its ability to automatically find wrong-code bugs. Our second contribution is a collection of qualitative and quantitative results about the bugs we have found in open-source C compilers.

References

  1. ACE Associated Computer Experts. SuperTest C/C+ compiler test and validation suite. http://www.ace.nl/compiler/supertest.htmlGoogle ScholarGoogle Scholar
  2. F. Bellard. TCC: Tiny C compiler, ver. 0.9.25, May 2009. http://bellard.org/tcc/.Google ScholarGoogle Scholar
  3. C. L. Biffle. Undefined behavior in Google NaCl, Jan. 2010. http://code.google.com/p/nativeclient/issues/detail?id=245.Google ScholarGoogle Scholar
  4. A. S. Boujarwah and K. Saleh. Compiler test case generation methods: a survey and assessment. Information and Software Technology, 39(9):617--625, 1997.Google ScholarGoogle ScholarCross RefCross Ref
  5. C. J. Burgess and M. Saidi. The automatic generation of test cases for optimizing Fortran compilers. Information and Software Technology, 38(2):111--119, 1996.Google ScholarGoogle ScholarCross RefCross Ref
  6. E. Eide and J. Regehr. Volatiles are miscompiled, and what to do about it. In Proc. EMSOFT, pages 255--264, Oct. 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. X. Feng and A. J. Hu. Cutpoints for formal equivalence verification of embedded software. In Proc. EMSOFT, pages 307--316, Sept. 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. P. Godefroid, A. Kiezun, and M. Y. Levin. Grammar-based whitebox fuzzing. In Proc. PLDI, pages 206--215, June 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. Hamlet. Random testing. In J. Marciniak, editor, Encyclopedia of Software Engineering. Wiley, second edition, 2001.Google ScholarGoogle Scholar
  10. K. V. Hanford. Automatic generation of test cases. IBM Systems Journal, 9(4):242--257, Dec. 1970. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. International Organization for Standardization. ISO/IEC 9899:TC2: Programming Languages-C, May 2005. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf.Google ScholarGoogle Scholar
  12. G. Klein et al. seL4: Formal verification of an OS kernel. In Proc. SOSP, pages 207--220, Oct. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. C. Knight and N. G. Leveson. An experimental evaluation of the assumption of independence in multiversion programming. IEEE Trans. Software Eng., 12(1):96--109, Jan. 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. X. Leroy. Formal verification of a realistic compiler. Commun. ACM, 52(7):107--115, July 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. C. Lindig. Random testing of C calling conventions. In Proc. AADEBUG, pages 3--12, Sept. 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. W. M. McKeeman. Differential testing for software. Digital Technical Journal, 10(1):100--107, Dec. 1998.Google ScholarGoogle Scholar
  17. B. P. Miller, L. Fredriksen, and B. So. An empirical study of the reliability of UNIX utilities. Commun. ACM, 33(12):32--44, Dec. 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. G. Misherghi and Z. Su. HDD: Hierarchical delta debugging. In Proc. ICSE, pages 142--151, May 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Perennial, Inc. ACVS ANSI/ISO/FIPS-160 C validation suite, ver. 4.5, Jan. 1998. http://www.peren.com/pages/acvs_set.htm.Google ScholarGoogle Scholar
  20. Plum Hall, Inc. The Plum Hall validation suite for C. http://www.plumhall.com/stec.html.Google ScholarGoogle Scholar
  21. P. Purdom. A sentence generator for testing parsers. BIT Numerical Mathematics, 12(3):366--375, 1972.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. R. L. Sauder. A general test data generator for COBOL. In AFIPS Joint Computer Conferences, pages 317--323, May 1962. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. F. Sheridan. Practical testing of a C99 compiler using output comparison. Software--Practice and Experience, 37(14):1475--1488, Nov. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J. Souyris, V. Wiels, D. Delmas, and H. Delseny. Formal verification of avionics software products. In Proc. FM, pages 532--546, Nov. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. Summit. comp.lang.c frequently asked questions. http://c-faq.com/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Z. Tatlock and S. Lerner. Bringing extensibility to verified compilers. In Proc. PLDI, pages 111--121, June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. B. Turner. Random Program Generator, Jan. 2007. http://sites.google.com/site/brturn2/randomcprogramgenerator.Google ScholarGoogle Scholar
  28. B. White et al. An integrated experimental environment for distributed systems and networks. In Proc. OSDI, pages 255--270, Dec. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. D. S. Wilkerson. Delta ver. 2006.08.03, Aug. 2006. http://delta.tigris.org/.Google ScholarGoogle Scholar
  30. M. Wolfe. How compilers and tools differ for embedded systems. In Proc. CASES, Sept. 2005. Keynote address. http://www.pgroup.com/lit/articles/pgi_article_cases.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. A. Zeller and R. Hildebrandt. Simplifying and isolating failure-inducing input. IEEE Trans. Software Eng., 28(2):183--200, Feb. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. C. Zhao et al. Automated test program generation for an industrial optimizing compiler. In Proc. ICSE Workshop on Automation of Software Test, pages 36--43, May 2009.Google ScholarGoogle Scholar

Index Terms

  1. Finding and understanding bugs in C compilers

        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 ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 46, Issue 6
          PLDI '11
          June 2011
          652 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/1993316
          Issue’s Table of Contents
          • cover image ACM Conferences
            PLDI '11: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation
            June 2011
            668 pages
            ISBN:9781450306638
            DOI:10.1145/1993498
            • General Chair:
            • Mary Hall,
            • Program Chair:
            • David Padua

          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: 4 June 2011

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader