博客地址:http://home.cnblogs.com/u/zengjianrong/

address sanitizer

  • -fsanitize=address:Enable AddressSanitizer. The option cannot be combined with -fsanitize=thread or -fsanitize=hwaddress.
  • -fsanitize=hwaddress:Enable Hardware-assisted AddressSanitizer. The option cannot be combined with -fsanitize=thread or -fsanitize=address, and is currently only available on AArch64.
  • -fsanitize=thread:Enable ThreadSanitizer. The option cannot be combined with -fsanitize=address, -fsanitize=leak.
  • -fsanitize=leak:Enable LeakSanitizer. The option cannot be combined with -fsanitize=thread. 
  • -fsanitize-recover[=opts]:Enabling this option for a sanitizer component causes it to attempt to continue running the program as if no error happened.
  • -mno-omit-leaf-frame-pointer:Keep the frame pointer in a register for leaf functions. 
  • -fno-omit-frame-pointer:Keep the frame pointer for all functions, which might make debugging harder.

 

cmake 同时启用asan和tsan:

-DCMAKE_C_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=address -fsanitize=thread -fno-sanitize-recover=all"
-DCMAKE_CXX_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=address -fsanitize=thread -fno-sanitize-recover=all "

 

启动时的选项

export ASAN_OPTIONS=halt_on_error=0:malloc_context_size=100:log_path=./asan.log
export TSAN_OPTIONS=log_path=./tsan.log

export ASAN_OPTIONS=halt_on_error=0:malloc_context_size=100:detect_leaks=0:verbosity=1:log_path=./asan_raw.log
posted @ 2021-06-03 10:59  black_man  阅读(150)  评论(0编辑  收藏  举报