Run the fuzz targets¶
The libFuzzer targets are off unless the build asks for them. They need Clang. A sanitizer build is what makes the crashes these targets look for visible.
Build¶
CC=clang CXX=clang++ meson setup build-fuzz \
-Dwith_tests=true -Duse_hdf5=false -Dwith_fuzzers=true \
-Db_sanitize=address,undefined -Db_lundef=false
ninja -C build-fuzz tests/fuzz_capi_calls tests/fuzz_environment_types \
tests/fuzz_seed_kernel tests/fuzz_readcon_frame
fuzz_toml_config and fuzz_binary_config are the Cap’n Proto
configuration parsers. They are built only when the same setup also
passes -Duse_capnp=true. fuzz_readcon_frame is built only when
use_readcon is on, which is the default.
Run¶
Each target reads a corpus directory and stops after three minutes. Half the machine’s cores is the most to run at once. One target is shown here; the others take the same flags and their own corpus.
./build-fuzz/tests/fuzz_capi_calls -max_total_time=180 -rss_limit_mb=2048 \
-timeout=10 tests/fuzz/corpus/capi
The corpora are:
Target |
Corpus |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
fuzz_readcon_frame treats a leading zero byte as a synthetic frame
and any other leading byte as a .con file. The other targets read
their inputs as the text or opcode stream the source comment describes.
libFuzzer prints exec/s and an edge count (cov:) when it stops.
A crash is a file under the working directory. Minimize it with
-minimize_crash=1 and keep the result as a regression test.