bolero icon indicating copy to clipboard operation
bolero copied to clipboard

On master, rustc 1.61.0 fails to link fibonacci example with --sanitizer NONE

Open Ekleog opened this issue 2 years ago • 2 comments

Hi!

Following https://github.com/camshaft/bolero/issues/71, I switched to using cargo-bolero from commit 7187c3febbb7ac4dad71a5b6eca42a5039869fa6.

Then, trying to build the fibonacci example with stable rustc (so 1.61.0 as of this writing), I'm now getting the following linker error:

   Compiling test-bolero v0.1.0 (/home/ekleog/prog/test-bolero)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/x86_64-unknown-linux-gnu/release/deps/test_bolero-03796c9c1fd7ff1a.test_bolero.a997a281-cgu.0.rcgu.o" "/home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/x86_64-unknown-linux-gnu/release/deps/test_bolero-03796c9c1fd7ff1a.rufpas6580vdgtv.rcgu.o" "-Wl,--as-needed" "-L" "/home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/x86_64-unknown-linux-gnu/release/deps" "-L" "/home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/release/deps" "-L" "/home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/x86_64-unknown-linux-gnu/release/build/bolero-libfuzzer-41b6a54ed54d4993/out" "-L" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-efede371ca078f25.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-84fb18ba7592ffd9.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-a1dc360b97cf3afc.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-4220d815fd1849e6.rlib" "-Wl,--start-group" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-05b39ac0cb4c5688.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-ccaa149b737d6503.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-a94a6388c153126b.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-1ecfa264246b85c6.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-ee710154a50440b8.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-f09986d873ea8592.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-f3521e20c99619ab.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-df6036c77d75ce21.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-24f91c1a1dfc7e13.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-bffcc61991adb202.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-cf22313353d8663e.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-c45fb100f99430e9.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-0cdc47a8a81950ea.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-f1e158606c4c82f6.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-0b608b5ef4df0ec4.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-b8438dc0bcbbcc08.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-70e2ae036775ff2f.rlib" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-815d281f7068a893.rlib" "-Wl,--end-group" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-377835cfab8dae0d.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/ekleog/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/x86_64-unknown-linux-gnu/release/deps/test_bolero-03796c9c1fd7ff1a" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs" "-fuse-ld=gold"
  = note: /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:118: error: undefined reference to '__sancov_lowest_stack'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227: error: undefined reference to '__sanitizer_cov_trace_pc_indir'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:139: error: undefined reference to '__sancov_lowest_stack'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:145: error: undefined reference to '__sancov_lowest_stack'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:2132: error: undefined reference to '__sancov_lowest_stack'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/cmp.rs:1396: error: undefined reference to '__sanitizer_cov_trace_cmp8'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:388: error: undefined reference to '__sanitizer_cov_trace_cmp8'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:388: error: undefined reference to '__sanitizer_cov_trace_cmp8'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227: error: undefined reference to '__sanitizer_cov_trace_pc_indir'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/cmp.rs:1396: error: undefined reference to '__sanitizer_cov_trace_cmp8'
          /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/cmp.rs:1396: error: undefined reference to '__sanitizer_cov_trace_const_cmp8'
          /home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/x86_64-unknown-linux-gnu/release/deps/test_bolero-03796c9c1fd7ff1a.test_bolero.a997a281-cgu.0.rcgu.o:test_bolero.a997a281-cgu.0:function sancov.module_ctor_8bit_counters: error: undefined reference to '__sanitizer_cov_8bit_counters_init'
          /home/ekleog/prog/test-bolero/target/fuzz/build_71e6fd6154e07acb/x86_64-unknown-linux-gnu/release/deps/test_bolero-03796c9c1fd7ff1a.test_bolero.a997a281-cgu.0.rcgu.o:test_bolero.a997a281-cgu.0:function sancov.module_ctor_8bit_counters: error: undefined reference to '__sanitizer_cov_pcs_init'
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `test-bolero` due to previous error
error: process exited with status 101

It seems to me like libfuzzer is missing some stuff from sancov it's expecting to have when being built with --sanitizer NONE.

When trying with --engine afl, it's only missing __sanitizer_cov_trace_pc_guard, and trying with --engine honggfuzz I'm getting invalid fuzzer "honggfuzz".

Maybe sancov still needs to be enabled even when sanitizers are disabled in order for fuzzers to know the pc trace? But then I'm not sure whether it can actually be enabled on stable :/

Ekleog avatar May 25 '22 12:05 Ekleog