-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat(fuzz): Adds a fuzz harness for the starlark executor #64
Conversation
Hi @silvergasp! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
What did it find? I tried adding a fuzzer a while ago, what it found what various overflows, e.g. attempt to calculate |
I haven't had the chance to go through all the crashing test cases yet. So there may be more, but here are the ones I've found so far;
If you are keen on trying out the fuzzer you'll get the best results by copying all the
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
We have discussed fuzzer in our internal meeting. We think that we want to have fuzzer after all the problems fuzzer can find are eliminated — so we could run a few fuzzer iterations in CI. Otherwise it will be maintenance burden with little profit. |
No worries, that sounds reasonable. I'll add that having regularly scheduled fuzz testing in place can also be handy in catching regressions, rather than just existing bugs :) If you've got any queries about this fuzz harness or the maintenance required I'd be happy to clarify things :) |
How it can be done? For example, in your case of + stack overflow, can there be some rule like if it is stack overflow, than ignore this input? |
Yeah, there is a tool that is integrated into clusterfuzz/oss-fuzz that does this quite nicely. There are some docs here. It looks something like this on the web UI; The StackOverflow bug would look pretty much the same except with a "StackOverflow" title. Essentially the OSS-fuzz (which is just an instance of google/clusterfuzz);
So while it's not easily doable to do all that filtering and categorizing with just the code in this PR if this project was integrated into google/oss-fuzz it would be relatively straightforward. An alternative to oss-fuzz would be to run your own instance of google/clusterfuzz although that would likely work against the goal of minimising your maintenance burden. |
let module: Module = Module::new(); | ||
let mut eval: Evaluator = Evaluator::new(&module); | ||
let value = std::hint::black_box(eval.eval_module(ast, &globals)?); | ||
_ = std::hint::black_box(format!("{value:?}")); |
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.
I thought you would have needed to do let _ = ...
here. But playground suggests I'm wrong. Surprising.
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.
Yeah, I only found that fairly recently, too. Apparently, omitting the 'let' has been possible since rust 1.59
I don't think we want to run our own instance of clusterfuzz. But if we can easily ignore the issues we don't care about (e.g. those which are resource exhaustion of some form - either stack overflow or using too much memory) then that sounds good. Are you @silvergasp volunteering to set up oss-fuzz and ignore those? If so, the value seems good. |
Yeah, I'm happy to do that. I'll open up a PR with oss fuzz over the next couple days. |
001ad4a
to
e4a2010
Compare
@ndmitchell has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Great, I'll see to getting this code merged. Thanks for your efforts on fuzz testing! |
@ndmitchell merged this pull request in 158a5a8. |
Summary: This PR adds a basic fuzz test for the starlark parser and executor. The fuzzer has found a couple of non-critical bugs already :) so hopefully it'll be of some use to you :) X-link: facebook/starlark-rust#64 Reviewed By: stepancheg Differential Revision: D43697975 Pulled By: ndmitchell fbshipit-source-id: f8274390e804bafc4003d7018930ede14a506dd4
This PR adds a basic fuzz test for the starlark parser and executor. The fuzzer has found a couple of non-critical bugs already :) so hopefully it'll be of some use to you :)