Skip to content
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

Add fuzzing for the rust parser #9

Merged
merged 1 commit into from
Feb 1, 2024
Merged

Conversation

stusmall
Copy link
Contributor

This adds a fuzzing task for the rust parser. This is run as release to avoid various debug assertions in the project. I've had this running on my workstation and it hasn't found anything, but it is useful to keep in CI to catch regressions.

I recongize that fuzzing adds extra time to the pipeline, so I did a few things to try and minimize the impact.

  • First, it is a seperate, parallel workflow. Since the main build and test is a debug build and fuzz is a release build there is very little wasted work in rebuilding.
  • Second, I added caches for both tasks. This should help keep build time town in general.
  • The time the fuzzing task will run is capped at 2 minutes. This is pretty short. This was picked to not be too much longer than previous runs. This is a bit of a trade off. The longer this value is, the better the coverage.

Later I will take a look at having it excercise more parser configuration options to get better coverage. At first I just wanted to try and cover the default case well.

@stusmall stusmall force-pushed the add-fuzzing branch 2 times, most recently from 19d8f63 to e2cfeb7 Compare January 31, 2024 16:28
@stusmall stusmall marked this pull request as ready for review January 31, 2024 16:29
@stusmall stusmall force-pushed the add-fuzzing branch 4 times, most recently from dd50c70 to 9439870 Compare January 31, 2024 16:42
This adds a fuzzing task for the rust parser.  This is run as release
to avoid various debug assertions in the project.  I've had this
running on my workstation and it hasn't found anything, but it is
useful to keep in CI to catch regressions.

I recongize that fuzzing adds extra time to the pipeline, so I did a
few things to try and minimize the impact.

* First, it is a seperate, parallel workflow.  Since the main build
  and test is a debug build and fuzz is a release build there is very
  little wasted work in rebuilding.
* Second, I added caches for both tasks.  This should help keep build
  time town in general.
* The time the fuzzing task will run is capped at 2 minutes.  This is
  pretty short.  This was picked to not be too much longer than
  previous runs.  This is a bit of a trade off.  The longer this
  value is, the better the coverage.

Later I will take a look at having it excercise more parser
configuration options to get better coverage.  At first I just wanted
to try and cover the default case well.
@dubadub
Copy link
Contributor

dubadub commented Jan 31, 2024

Looks good to me, what do you think @Zheoni?

@Zheoni
Copy link
Contributor

Zheoni commented Jan 31, 2024

I'm not familiar with fuzz testing. I understand that it tries random inputs to check that the parser doesn't panic, is that correct?

If that's it I'm happy to merge this, caching the builds it's great too! 😄

@stusmall
Copy link
Contributor Author

stusmall commented Jan 31, 2024

Yup. The idea is that it will generate random input and observes coverage. It mutates the input to try and maximize coverage. It's really useful for things like this that take broad, plaintext input and parses it. It helps shake out hidden panics, logic bugs, unicode mistakes, infinite loops and various crashes.

Fuzzers are generally fairly dumb and don't give you a lot of input on if the parsing was "correct", just that it didn't explode

@Zheoni Zheoni merged commit 281f52d into cooklang:main Feb 1, 2024
3 checks passed
@Zheoni
Copy link
Contributor

Zheoni commented Feb 1, 2024

Ok, seems like a good idea to have it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants