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

hypothesmith-inspired compiler fuzzer used to validate PEP 709 implementation #30

Open
carljm opened this issue May 19, 2023 · 1 comment

Comments

@carljm
Copy link

carljm commented May 19, 2023

Hi!

Thought you might be interested to know that I wrote (and @JelleZijlstra greatly improved) a compiler fuzzer to validate the implementation of PEP 709 (inlined comprehensions) in Python 3.12: https://github.com/carljm/compgenerator

I started out with Hypothesmith, but I wanted to constrain the generated examples a lot more, and as I started replacing Hypothesmith strategies one by one, I realized that it would be a lot simpler to work with AST rather than with LibCST. We're fuzzing the compiler, not the parser, so we don't care about syntactic trivia.

The resulting fuzzer works pretty well (although it's slow, because we filter too much; I haven't worked out yet how to better constrain generation so we don't have to filter so much), and it's caught, so far, I think five or six different bugs in the PEP 709 implementation (all now fixed.)

No particular action item here, feel free to close :)

I guess one possible thing to consider would be whether AST-based strategies would make any sense for Hypothesmith, for non-parser-focused uses.

@Zac-HD
Copy link
Owner

Zac-HD commented May 20, 2023

Awesome!

It seems like #28 would be a nice way to ensure that there are always some listcomps without rejection sampling - although the implementation is a bit of a lift to cover all node types.

Relatedly I love that you used the AST for easier implementation, but that doesn't seem to help much here if we want to have a cst-based strategy too. The runtime gains we can probably get with "swarm testing" to probabilistically disable all the weird flourishes - almost as fast as doing it always, but a bit less cognitive load (from fewer options) and a chance of finding unexpected bugs too...

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

No branches or pull requests

2 participants