Files
wasmtime/cranelift/isle/fuzz/fuzz_targets/compile.rs
Chris Fallin 56236fb58e ISLE: fix compile fuzz target, and fix a simple error-reporting bug. (#3845)
It seems our `compile` fuzz target for ISLE has not been regularly
tested, as it was never updated for the `isle` -> `cranelift_isle` crate
renaming. This PR fixes it to compile again.

This also includes a simple fix in the typechecking: when verifying that
a term decl is valid, we might insert a term ID into the name->ID map
before fully checking that all of the types exist, and then skipping
(for error recovery purposes) the actual push onto the term-signature
vector if one of the types does have an error. This phantom TID can
later cause a panic. The fix is to avoid adding to the map until we have
fully verified the term decl.
2022-02-23 14:34:32 -08:00

33 lines
819 B
Rust

#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|s: &str| {
let _ = env_logger::try_init();
let lexer = cranelift_isle::lexer::Lexer::from_str(s, "fuzz-input.isle");
log::debug!("lexer = {:?}", lexer);
let lexer = match lexer {
Ok(l) => l,
Err(_) => return,
};
let defs = cranelift_isle::parser::parse(lexer);
log::debug!("defs = {:?}", defs);
let defs = match defs {
Ok(d) => d,
Err(_) => return,
};
let code = cranelift_isle::compile::compile(&defs);
log::debug!("code = {:?}", code);
let code = match code {
Ok(c) => c,
Err(_) => return,
};
// TODO: check that the generated code is valid Rust. This will require
// stubbing out extern types, extractors, and constructors.
drop(code);
});