c - Using Address Sanitizer as an alternative to Valgrind -


i have read address sanitizer available alternative valgrind. it, have started simple example. have written below given code use_after_free.c

#include<stdio.h> #include<stdlib.h>  int garray[100];  int main() { int *arr = (int*)malloc(5*sizeof(int)); arr[1]=45; printf("before free : arr[1] = %d\n",arr[1]); free(arr); printf("after free : arr[1] = %d\n",arr[1]); printf("garray[101] : %d\n",garray[105]); return 0; } 

i have installed following libraries :

1) apt-get install llvm  2) apt-get install clang 

then have compiled code using following command :

clang -o1 -g -fsanitize=address -fno-omit-frame-pointer use_after_free.c 

when executed binary has been created using above command, expecting errors address sanitizer. getting output without errors. there thing wrong approach?

edit : using ubuntu 12.04, llvm 3.1 , clang 3.1

ubuntu 12.04 brings clang 3.0, 3.3 , 3.4, not 3.1. either using 3.0 release (which not have support address sanitizer , silently swallows -fsanitize=address) or using unmentioned 3rd-party sources. clang --version tell?

for solution: apt-get install clang-3.4 resolve problem.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -