Skip to content

Detecting memory leaks

Yulei Sui edited this page Apr 16, 2020 · 22 revisions

1. Build SVF

Please refer to SVF setup

2. Compile your project into LLVM bc files

clang -c -emit-llvm -g example.c -o example.bc

To compile a complicated real-world project you may wish to use WLLVM guide to install it.

Compile your example.c into an executable and extract it into example.bc

wllvm example.c
extract example

3. Run SVF's memory leak detector on the generated bc file

cd SVF
. ./setup
saber -leak -stat=false example.bc

4. The printed memory leak results when analyzing this test case

	 PartialLeak : memory allocation at : (ln: 23 fl: sp1.c)
		 conditional free path: 
		  --> (ln: 12 fl: sp1.c) 

Clone this wiki locally