Skip to content

An llvm implementation of a memory leak analysis by contradiction.

License

Notifications You must be signed in to change notification settings

yige-hu/MemoryLeakAnalysis

Repository files navigation

Memory Leak Analysis by Contradiction

Yige Hu

CS380c final project:

Memory leak analysis by contradiction. It is an intra-procedural backward dataflow analysis to detect potential memory leakage on heap cells, implemented using LLVM.

References:

Memory leak analysis by contradiction
In Proceedings of the 13th international conference on Static Analysis (SAS'06), 2006.

The paper describes a backward dataflow analysis for both intra- and inter-procedual analysis. Due to the time constraint, only the intra-procedual analysis is implemented in this work.

Program catalog:

  • Dataflow.h:

    A basic framework for Data-flow analysis.

  • SetOperations.h:

    Some basic tools for set operations.

  • LeakAnalysis.h:

    A memory-leak analysis.

  • MemLeak.h & cpp:

    The leak pass.

  • (*) FunctionInfo.cpp:

    An auxiliary and independent tool to print out some function info.

  • (*) SamplePass.cpp:

    An auxiliary and independent tool to show the usage of the Andersen's analysis. Provided by Jia (grievejia).

Usage:

For the compatibility purpose with Jia's Andersen's analysis, LLVM is strongly suggested to be installed with v3.5, trunk 203470.

  • Install the Andersen's pointer analysis implemented by Jia:

    https://github.com/grievejia/andersen

  • Compile memLeak analysis:

    Change the "ANDERS_DIR" in Makefile into the directory of the Andersen's analysis installed in step 1. Run:

  make memLeak
  • Automatically run all the microbenchmarks:

    Change the "ANDERS_DIR" in "run_microbench.sh" into the directory of the Andersen's analysis. Run:

  ./run_microbench.sh
  • Analyze other C programs:

    Prepare for the .bc input:

  ./prepare.sh [c file names (without .c)]

e.g.

  ./prepare.sh benchmark/glibc_math/atest-sincos

Run memLeak pass:

  opt -load ../andersen/Debug+Asserts/lib/libAnders.so -load ./MemLeak.so -leak-pass atest-sincos.bc > /dev/null
  • (*) For reference, the usage of the SamplePass and FunctionInfo:
  opt -load ./FunctionInfo.so -function-info testcase1.bc

  opt -load ../andersen/Debug+Asserts/lib/libAnders.so -load ./SamplePass.so -sample-pass testcase1.bc > /dev/null

About

An llvm implementation of a memory leak analysis by contradiction.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published