c++ - 是否可以将 AddressSanitizer 和 ThreadSanitizer 合并到一个版本中?

标签 c++ gcc

或者我必须使用单独的版本吗? -fsanitize 标志仅允许地址或线程,但是否允许多个?

问候

最佳答案

不,不可能将 AddressSanitizer 和 ThreadSanitizer 组合到一个版本中(但其他组合也是可能的)。您需要多个构建

-fsanitize=address

Enable AddressSanitizer, a fast memory error detector. Memory access instructions are instrumented to detect out-of-bounds and use-after-free bugs. The option enables -fsanitize-address-use-after-scope. See https://github.com/google/sanitizers/wiki/AddressSanitizer for more details. The run-time behavior can be influenced using the ASAN_OPTIONS environment variable. When set to help=1, the available options are shown at startup of the instrumented program. See https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags for a list of supported options. The option cannot be combined with -fsanitize=thread or -fsanitize=hwaddress. Note that the only target -fsanitize=hwaddress is currently supported on is AArch64.

-fsanitize=thread

Enable ThreadSanitizer, a fast data race detector. Memory access instructions are instrumented to detect data race bugs. See https://github.com/google/sanitizers/wiki#threadsanitizer for more details. The run-time behavior can be influenced using the TSAN_OPTIONS environment variable; see https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags for a list of supported options. The option cannot be combined with -fsanitize=address, -fsanitize=leak.

Note that sanitized atomic builtins cannot throw exceptions when operating on invalid memory addresses with non-call exceptions (-fnon-call-exceptions).

https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html

关于c++ - 是否可以将 AddressSanitizer 和 ThreadSanitizer 合并到一个版本中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68907684/

相关文章:

c++ - IUnknown 中的 addref 和 release,它们实际上是做什么的?

c++ - 在静态成员数组定义中对自身使用 sizeof 运算符

c - gcc -nostdlib 和 mudflap

c++ - 在 Boost 中的 GCC 3.3 问题下使用 operator() 进行编译

c++ - 在 Iinux 操作系统(自定义板)上运行的应用程序不会从导出的 LD_LIBRARY_PATH 中读取共享库

c++ - 无法更改背景颜色 MDI c++

linux - PATH 和 COMPILER_PATH 之间的区别

c++ - 为什么包裹在函数中的 GAS 内联汇编为调用者生成与纯汇编函数不同的指令

gcc - 如何编译和运行 GCC 4.9.x?

c++ - 了解类对象构造