cargo-fuzz
cargo-fuzz copied to clipboard
Linker errors with stdweb.
I'm trying to set up cargo-fuzz for a web-based project. For production we deploy to wasm (using cargo-web) however we run are tests natively as well so the project runs just fine on x86. In fact we have AFL set up with a regular binary which works for fuzzing, however I figured I would try out libfuzzer as well.
When compiling with cargo fuzz run we get many linker errors such as in function <alloc::vec::IntoIter<T> as core::ops::drop::Drop>::drop': main.1d8o2qxf-cgu.0:(.text._ZN71_$LT$alloc..vec..IntoIter$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h62c937e915a268ffE+0x316): undefined reference to emscripten_asm_const_int. Indicating that for some reason LLVM functions are being used even though they shouldn't be.
I have ensured that we are compiling with LTO however this doesn't seem to help.
Working bin target:
fn main() {
onuw::fuzz::fuzz("binary", std::io::stdin().lock());
}
Failing cargo-fuzz target:
#![no_main]
use libfuzzer_sys::fuzz_target;
libfuzzer_sys::fuzz_target!(|data: &[u8]| {
onuw::fuzz::fuzz("binary", data);
});
It would be really nice if this worked.
It appears that the stdweb crate used by cargo-web is basically incompatible with cargo-fuzz.
Simply referencing a function such as console!(log, "Anything") is enough to break the build.