Reputation: 301
I am trying to use Address Sanitizer with gcc in my project.
So, I added the required flags in compiler as well as linker :
ADD_COMPILE_OPTIONS(-O0 -g -Wall -fsanitize=address -fno-omit-frame-pointer)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
Address Sanitizer is working after this, but it aborts my application after the first error. I want the Address Sanitizer to continue running even after reporting the error. So, I added one more flag like below (as per the link https://github.com/google/sanitizers/wiki/AddressSanitizer) :
ADD_COMPILE_OPTIONS(-O0 -g -Wall -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer)
After this I am getting the error that this recover flag is not supported :
Problems were encountered while collecting compiler information:
cc1plus: error: -fsanitize-recover=address is not supported
PS : My gcc version is gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
Upvotes: 2
Views: 6929
Reputation: 21954
I believe gcc 6 is the earliest version that supports Asan recovery mode. This mode was added in Nov 2015 whereas GCC 5 was released in April 2015.
You can install GCC 6 or use Clang.
Upvotes: 1