Memory Safety Without Runtime Checks or Garbage Collection
Dinakar Dhurjati, Sumant Kowshik, Vikram Adve and Chris Lattner

Abstract:

Traditional approaches to enforcing memory safety of programs rely heavily on runtime checks of memory accesses and on garbage collection, both of which are unattractive for embedded applications. The long-term goal of our work is to enable 100% static enforcement of memory safety for embedded programs through advanced compiler techniques and minimal semantic restrictions on programs. The key result of this paper is a compiler technique that ensures memory safety of dynamically allocated memory without programmer annotations, runtime checks, or garbage collection, and works for a large subclass of type-safe C programs. The technique is based on a fully automatic pool allocation (i.e., region-inference) algorithm for C programs we developed previously, and it ensures safety of dynamically allocated memory while retaining explicit deallocation of individual objects within regions (to avoid garbage collection). For a diverse set of embedded C programs (and using a previous technique to avoid null pointer checks), we show that we are able to statically ensure the safety of pointer and dynamic memory usage in all these programs. We also describe some improvements over our previous work in static checking of array accesses. Overall, we achieve 100% static enforcement of memory safety without new language syntax for a significant subclass of embedded C programs, and the subclass is much broader if array bounds checks are ignored.

Published:

"Memory Safety Without Runtime Checks or Garbage Collection", Dinakar Dhurjati, Sumant Kowshik, Vikram Adve & Chris Lattner,
LCTES 2003, San Diego, CA, June 2003.

Download:

BibTeX Entry:

  @InProceedings{DKAL:LCTES03,
    Author    = {Dinakar Dhurjati, Sumant Kowshik, Vikram Adve and Chris Lattner},
    Title     = "{Memory Safety Without Runtime Checks or Garbage Collection}",
    Booktitle = "{Proc. Languages Compilers and Tools for Embedded Systems 2003}",
    Address   = {San Diego, CA},
    Month     = {June},
    Year      = {2003},
    URL       = {http://llvm.cs.uiuc.edu/pubs/2003-05-05-LCTES03-CodeSafety.html}
  }

Links:

SAFECode project