目前在 Windows 上的 Ubuntu Bash 上运行 llvm、clang、clang-format 和 clang-modernize。我想使用谷歌发布的一组清理工具,包括地址、内存和线程清理。 fsanitize 选项似乎都不起作用。
这是 ASAN 的代码示例:
#include <stdlib.h>
int main() {
char *x = (char *)malloc(10 * sizeof(char *));
free(x);
return x[5];// purposely accessing deallocated memory
}
这是在 Windows 上的 bash 中的 clang 调用:
$clang++-3.5 -fsanitize=address -o1 -fno-omit-frame-pointer -g main.cpp -o main
$./main
结果
==70==Sanitizer CHECK failed: build/buildd/llvm-toolchain-snapshot-3.5/projects/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc:211 ((IsOneOf(*current_, 's', 'p'))) != (0)(0,0)
如果我缺少工具链的一部分或其他东西,我会喜欢关于如何让它工作的建议。
如果失败,我想我会双启动 Ubuntu 或 Debian,因为 clang for windows 缺少简单的功能,如 std:out 支持,但理想情况下我希望能够同时针对 Windows 目标和 Linux 目标进行编译。我想避免双启动,因为 Ubuntu 无法安装 Windows 存储空间,但它们似乎很好地服务于 Windows 上的 Ubuntu bash。
最佳答案
快速浏览一下源代码 - MemoryMappingLayout::Next - https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_linux.cc - 看来问题是 Windows 上的 ubuntu 上的 bash 对/proc 文件系统的支持不完整。
失败的代码是查看/proc/self/maps - 实际上 - 似乎是正确的。
但我发现/proc 中的其他内容(例如网络)在 bashonwindowsonunix 上完全损坏 - 所以我很确定这部分工作正在进行中。
关于c++ - 地址清理器不适用于 Windows 上的 bash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52510753/