或者我必须使用单独的版本吗? -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/