-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic fuzzing harness #126
base: main
Are you sure you want to change the base?
Conversation
Would appreciate a double check of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! A few comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This target is redundant since the canonicalize
function is implemented using the standard library, and it's also coming from dunce
, not implemented here.
|
||
let _ = sess.enter(|| -> solar_interface::Result<()> { | ||
let mut pcx = solar_sema::ParsingContext::new(&sess); | ||
pcx.load_file(&path).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can avoid the temp file by using add_file
with a SourceFile
created in memory, like so:
let Ok(data) = std::str::::from_utf8(data) else {
return Ok(());
};
let Ok(file) = sess.source_map().new_dummy_source_file("fuzz".into(), data.to_string()) else {
return;
};
pcx.add_file(file);
solar-parse = { path = "../crates/parse" } | ||
solar-interface = { path = "../crates/interface" } | ||
solar-sema = { path = "../crates/sema" } | ||
solar-cli = { path = "../crates/cli" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use .workspace = true
instead for these dependencies
This PR adds a basic fuzzing harness to Solar using
cargo-fuzz
, a popular frontend to thelibfuzzer
fuzzing engine.Specifically, this PR contains the following cases:
run_compiler_args
, a (reasonably close to) end-to-end case for the entire compilerparsing_context_parse_and_resolve
, specifically targeting just parsing and semantic analysiscanonicalize
, targeting path canonicalisation (low-hanging and likely uninteresting, but added for posterity)The intent (and expectation) is that this PR will allow for easy extension and expansion of fuzzing cases as development of the compiler progresses.