chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.77k stars 417 forks source link

Adding fuzz testing of the compiler #25487

Open jabraham17 opened 2 months ago

jabraham17 commented 2 months ago

There have been previous attempts at fuzz testing the Chapel compiler, to some success (see https://github.com/chapel-lang/chapel/issues/13097 and https://github.com/chapel-lang/chapel/issues/9987). These attempts have a caught various internal issues with the compiler. I think we should integrate proper fuzz testing as a part of our testing suite and I could find no other issue on this topic.

What is fuzzing

Fuzzing is an automated way of generating inputs for a system to test for unexpected inputs. For Chapel's use case, this would look like Chapel source code that might cause an internal error.

Previous attempts

Proposals

Both of the previous attempts used mutation fuzzing, taking existing good programs and tweaking them. I think we could probably find a third-party fuzzing tool that does a good job of mutation based fuzzing, and just point it to our existing test repo. https://www.fuzzingbook.org/html/MutationFuzzer.html seems to have some good resources for this.

Another approach would be to use the existing grammar to drive a fuzzer. https://www.fuzzingbook.org/html/Grammars.html has some resources for this.

DanilaFe commented 2 months ago

I know that Xsmith can be used to generate "type-correct" programs for fuzzing. That said, I'm not sure that it's worth the investment.