我想要在clang/gcc中抑制地址检测器的警告。
我的源文件如下:
int foo(){
double bar[] = {7,8};
return bar[3];
}
int main(){
return foo();
}
显然,在第三行存在溢出。
抑制文件(myasan.supp)包含:
interceptor_via_fun:foo
编译(clang还会创建一个警告)并运行:
clang -O0 -g -fsanitize=address -fno-omit-frame-pointer sanitizerTest.c
ASAN_SYMBOLIZER_PATH=/software/clang/7.0.0/bin/llvm-symbolizer ASAN_OPTIONS=suppressions=myasan.supp ./a.out
但是地址泄漏检测器仍然抱怨溢出。
==8119==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffeab4e75f8 at pc 0x0000004008bf bp 0x7ffeab4e75b0 sp 0x7ffeab4e75a8
READ of size 8 at 0x7ffeab4e75f8 thread T0
#0 0x4008be in foo() /tmp/asan/sanitizerTest.c:3
#1 0x400919 in main /tmp/asan/sanitizerTest.c:7
#2 0x7f549fbfb82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#3 0x400718 in _start (/tmp/asan/a.out+0x400718)
编译器是clang7。我也测试过clang6和gcc7。你有什么想法让它工作吗?
clang
/gcc
进行编译吗?还是使用clang++
/g++
? - Florian Weimer