loiclec / fuzzcheck-rs

Modular, structure-aware, and feedback-driven fuzzing engine for Rust functions
MIT License
435 stars 13 forks source link

Fuzzcheck can't run on NixOS #29

Open PoignardAzur opened 2 years ago

PoignardAzur commented 2 years ago

I tried to run FuzzCheck on NixOS to see if it had the same problems as I have on my Ubuntu desktop.

Predictably, the build instead failed due to completely unrelated errors.

Mostly it's looking for system libs and not finding them. I'm not sure how you could solve that with cargo install. Maybe I could try making a NixOS package directly.

My system:

PoignardAzur commented 2 years ago

Error messages:

error: failed to run custom build command for `fuzzcheck v0.11.0 (https://github.com/loiclec/fuzzcheck-rs#8f7de6fa)`

Caused by:
  process didn't exit successfully: `/home/olivier-faure/Documents/venial/target/fuzzcheck/fuzzing/build/fuzzcheck-79c9b2bdd54171d2/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_x86_64-unknown-linux-gnu = None
  CC_x86_64_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-linux-gnu = None
  CFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,llvm14-builtins-abi,sse,sse2")
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-Wall" "-Wextra" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/fuzzcheck-639136dc22a41961/out/src/code_coverage_sensor/instrumentation_pointers_linux.o" "-c" "src/code_coverage_sensor/instrumentation_pointers_linux.c"
  exit status: 0
  AR_x86_64-unknown-linux-gnu = None
  AR_x86_64_unknown_linux_gnu = None
  HOST_AR = None
  AR = None
  running: "ar" "cq" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/fuzzcheck-639136dc22a41961/out/libinstrumentation_pointers.a" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/fuzzcheck-639136dc22a41961/out/src/code_coverage_sensor/instrumentation_pointers_linux.o"

  --- stderr

  error occurred: Failed to find tool. Is `ar` installed?

warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `libz-sys v1.1.5`

Caused by:
  process didn't exit successfully: `/home/olivier-faure/Documents/venial/target/fuzzcheck/fuzzing/build/libz-sys-52c1be84bec78157/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=LIBZ_SYS_STATIC
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-env-changed=ZLIB_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=ZLIB_STATIC
  cargo:rerun-if-env-changed=ZLIB_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo-warning=`"pkg-config" "--libs" "--cflags" "zlib"` did not exit successfully: exit status: 1
  error: could not find system library 'zlib' required by the 'libz-sys' crate

  --- stderr
  Package zlib was not found in the pkg-config search path.
  Perhaps you should add the directory containing `zlib.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'zlib' found

  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-unknown-linux-gnu")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_x86_64-unknown-linux-gnu = None
  CC_x86_64_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-linux-gnu = None
  CFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,llvm14-builtins-abi,sse,sse2")
  running "cc" "src/smoke.c" "-o" "/dev/null" "-lz"
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/adler32.o" "-c" "src/zlib/adler32.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/compress.o" "-c" "src/zlib/compress.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/crc32.o" "-c" "src/zlib/crc32.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/deflate.o" "-c" "src/zlib/deflate.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/infback.o" "-c" "src/zlib/infback.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/inffast.o" "-c" "src/zlib/inffast.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/inflate.o" "-c" "src/zlib/inflate.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/inftrees.o" "-c" "src/zlib/inftrees.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/trees.o" "-c" "src/zlib/trees.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/uncompr.o" "-c" "src/zlib/uncompr.c"
  exit status: 0
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/zutil.o" "-c" "src/zlib/zutil.c"
  exit status: 0
  AR_x86_64-unknown-linux-gnu = None
  AR_x86_64_unknown_linux_gnu = None
  HOST_AR = None
  AR = None
  running: "ar" "cq" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/libz.a" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/adler32.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/compress.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/crc32.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/deflate.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/infback.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/inffast.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/inflate.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/inftrees.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/trees.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/uncompr.o" "/home/olivier-faure/Documents/venial/target/fuzzcheck/x86_64-unknown-linux-gnu/fuzzing/build/libz-sys-031fbc85e9593500/out/lib/src/zlib/zutil.o"

  --- stderr
  src/smoke.c:1:10: fatal error: 'zlib.h' file not found
  #include <zlib.h>
           ^~~~~~~~
  1 error generated.

  error occurred: Failed to find tool. Is `ar` installed?
PoignardAzur commented 2 years ago

I managed to get it running with the following commands:

$ nix-shell -p rustup
$ cargo +nightly fuzzcheck fuzz::fuzz_parse --profile fuzzing

But now I have the same error as on my main PC:

running 1 test
test fuzz::fuzz_parse ... thread 'main' panicked at 'failed to properly link the different LLVM coverage sections: CannotFindFunctionRecordAssociatedWithPrfData("This can sometimes happen when the crate is incrementally compiled with more than one codegen-unit. Try adding codegen-units = 1 or incremental = false to the appropriate profile (release or fuzzing) in Cargo.toml")', /home/olivier-faure/.cargo/git/checkouts/fuzzcheck-rs-531eb3f95f61a5dd/8f7de6f/fuzzcheck/src/code_coverage_sensor/mod.rs:71:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
FAILED