我应该使用什么AddressSanitizer标志来检测更多错误?

时间:2017-09-11 04:02:00

标签: address-sanitizer

我应该使用哪些Asan标志来检测更多错误?目前,我使用ASAN_OPTIONS=detect_stack_use_after_return=1

2 个答案:

答案 0 :(得分:0)

来自Asan FAQ

Q: Can I run AddressSanitizer with more aggressive diagnostics enabled?

A: Yes! In particular you may want to enable

  CFLAGS += -fsanitize-address-use-after-scope
  ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1

Check https://github.com/google/sanitizers/wiki/AddressSanitizerFlags for more details on this.

答案 1 :(得分:0)

在命令行中,在编译时添加以下选项:

-fsanitize-recover=address -fsanitize=address

运行可执行文件时,请添加以下选项:

ASAN_OPTIONS=halt_on_error=0 ./your_executable_name

我在Ubuntu上尝试过的这些选项,在Windows中,我仍然找到答案。