大约半年前,我使用 VSCode 设置了一个 CMake 项目,该项目带有一个在 Windows 和 macOS 上运行的 libFuzzer 目标。我将 C++ 扩展与 Microsoft 的 CMakeTools 扩展一起使用。
当我现在再次恢复项目时,我在 fuzzer 运行结束时遇到错误:
ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting.
完整输出:
INFO: Seed: 2201882200
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: A corpus is not provided, starting from an empty corpus
#2 INITED exec/s: 0 rss: 61Mb
ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting.
与在 macOS 上运行的相同 fuzzer 相比:
INFO: Seed: 1824512455
INFO: Loaded 1 modules (7 inline 8-bit counters): 7 [0x10c2baa88, 0x10c2baa8f),
INFO: Loaded 1 PC tables (7 PCs): 7 [0x10c2baa90,0x10c2bab00),
INFO: 6 files found in /Users/thomas/SourceTree/vscode-cmake-libfuzzer/fuzzers/corpus/fuzz_test/
INFO: seed corpus: files: 6 min: 1b max: 10b total: 37b rss: 30Mb
#7 INITED cov: 1 ft: 1 corp: 1/1b exec/s: 0 rss: 30Mb
#1048576 pulse cov: 1 ft: 1 corp: 1/1b lim: 8192 exec/s: 524288 rss: 1099Mb
#2097152 pulse cov: 1 ft: 1 corp: 1/1b lim: 8192 exec/s: 699050 rss: 1100Mb
#4194304 pulse cov: 1 ft: 1 corp: 1/1b lim: 8192 exec/s: 599186 rss: 1101Mb
#5740032 DONE cov: 1 ft: 1 corp: 1/1b lim: 8192 exec/s: 521821 rss: 1101Mb
Done 5740032 runs in 11 second(s)
stat::number_of_executed_units: 5740032
stat::average_exec_per_sec: 521821
stat::new_units_added: 0
stat::slowest_unit_time_sec: 0
stat::peak_rss_mb: 1101
我如何链接 libFuzzer 的片段:(我必须手动将库添加到 Windows 以使其链接。)
# https://llvm.org/docs/LibFuzzer.html#fuzzer-usage
target_link_libraries(clang_fuzzer INTERFACE
-fsanitize=fuzzer,address
)
target_compile_options(clang_fuzzer INTERFACE
-fsanitize=fuzzer,address
)
测试模糊器:
#include <iostream>
#include <stddef.h>
#include <stdint.h>
bool FuzzMe(const uint8_t *Data, size_t DataSize) {
return DataSize >= 3 &&
Data[0] == 'F' &&
Data[1] == 'U' &&
Data[2] == 'Z' &&
Data[3] == 'Z'; // :‑<
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
// std::cout << "Hello Fuzzy...\n";
FuzzMe(data, size);
return 0;
}
最小的完整示例: https ://github.com/thomthom/vscode-cmake-libfuzzer
在 Windows 上,我通过可用的快照安装了 clang:https ://llvm.org/builds/
在 macOS 上我通过安装它brew install llvm
(因为 AppleClang 不包括 libFuzzer)
我已经在两台 Windows 机器上进行了测试,这两款机器以前都可以很好地运行模糊器,现在它们没有。但我无法弄清楚是什么导致了回归。我知道我没有在这两个系统上更新 Clang。一方面,我还尝试通过 Visual Studio 安装 Clang,并尝试从 VSCode 中选择该安装以查看它是否有任何区别,但无济于事。
我唯一能想到的另一件事是,在 VSCode-Tools 扩展更新了 Windows 的默认生成器后,我的 VSCode CMake 项目需要调整。不记得以前用什么了。如果这会影响 libFuzzer,我仍然觉得很奇怪。