Skip to main content
QUICK REVIEW

[Paper Review] 2LS: Heap Analysis and Memory Safety (Competition Contribution)

Viktor Malík, Martin Hruška|arXiv (Cornell University)|Mar 2, 2019
Formal Methods in VerificationComputer Science3 references5 citations
TL;DR

2LS is a static analysis framework for C programs that enhances heap analysis by combining shape and content invariants using template-based synthesis and incremental $k$-induction. It enables verification of memory safety properties—such as null pointer dereferences, use-after-free, and memory leaks—by instrumenting programs with assertions and leveraging SAT-based reasoning, achieving 9 out of 10 benchmarks in a new MemSafety category focused on complex data structures.

ABSTRACT

2LS is a framework for analysis of sequential C programs that can verify and refute program assertions and termination. The 2LS framework is built upon the CPROVER infrastructure and implements template-based synthesis techniques, e.g. to find invariants and ranking functions, and incremental loop unwinding techniques to find counterexamples and k-induction proofs. The main improvements in this year's version are the ability of 2LS to analyse programs requiring combined reasoning about shape and content of dynamic data structures, and an instrumentation for memory safety properties.

Motivation & Objective

  • Address the challenge of verifying complex heap-manipulating C programs that require joint reasoning about data structure shape and element values.
  • Improve memory safety verification by encoding assertions for null pointer dereferences, use-after-free, and memory leaks.
  • Extend the 2LS framework to support precise analysis of dynamic data structures through abstract domain combinations and symbolic path tracking.
  • Enable scalable verification of programs with unbounded data structures, such as singly-linked lists with value constraints, using incremental SAT solving.
  • Contribute new benchmarks to the SV-COMP competition to evaluate reasoning about shape and content in dynamic data structures.

Proposed method

  • Represent C programs as GOTO programs in single static assignment (SSA) form with loop unwinding and over-approximation.
  • Use template-based synthesis to compute inductive invariants in abstract domains, combining shape, zones (interval), and symbolic path domains.
  • Construct a product domain by conjoining shape and polyhedral (zones) invariants to reason jointly about pointer structure and numerical values.
  • Introduce symbolic paths to track which loops were executed, enabling path-sensitive invariants and power domain combination for improved precision.
  • Instrument programs with assertions to detect memory safety violations: $p \neq \mathtt{NULL}$ for null dereferences, $p \neq \mathit{fr}$ for use-after-free, and $\mathit{fr} \neq \&ao_{i}^{co}$ for memory leaks.
  • Leverage incremental SAT solving via the $k$-induction and $k$-invariant ($k$IkI) algorithm to prove or refute assertions and termination.

Experimental results

Research questions

  • RQ1Can a static analysis framework effectively combine shape and content reasoning for dynamic data structures in C programs?
  • RQ2How can memory safety properties—such as null pointer dereferences and use-after-free—be precisely encoded and verified using symbolic execution and invariant synthesis?
  • RQ3To what extent can template-based synthesis and domain combination improve the verification of complex heap-manipulating programs?
  • RQ4How effective is the symbolic path abstraction in improving precision for invariants over different program paths?
  • RQ5What is the scalability and accuracy of the $k$IkI algorithm in verifying programs with unbounded data structures and complex memory operations?

Key findings

  • 2LS successfully verified 9 out of 10 new benchmarks involving unbounded singly-linked lists with values constrained to the interval [1,10], demonstrating strong capability in joint shape and content analysis.
  • The framework outperformed all other tools in the SV-COMP MemSafety category, with no other tool verifying more than 3 of the 10 new shape-and-content benchmarks.
  • Memory safety checks for null pointer dereferences and use-after-free were encoded via assertions and proven sound using SAT-based reasoning, with no false positives reported in the competition.
  • Memory leak detection was proven sound only for programs without loops or with fully unwound loops, due to limitations in tracking all objects in abstract dynamic objects.
  • The tool achieved 4th place in the MemSafety category, narrowly missing the podium, with significant challenges remaining in termination analysis due to unconfirmed witnesses.
  • The $k$IkI algorithm demonstrated scalability for sequential C programs, but limitations remain in handling recursion and array content reasoning.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.