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

rework fuzzing API to accept a function pointer parameter #21370

Merged
merged 7 commits into from
Sep 12, 2024
Merged

Conversation

andrewrk
Copy link
Member

The previous API used std.testing.fuzzInput(.{}) however that has the problem that users call it multiple times incorrectly, and there might be work happening to obtain the corpus which should not be included in coverage analysis, and which must not slow down iteration speed.

This changeset restructures it so that the main loop lives in libfuzzer and directly calls the "test one" function.

The previous API used `std.testing.fuzzInput(.{})` however that has the
problem that users call it multiple times incorrectly, and there might
be work happening to obtain the corpus which should not be included in
coverage analysis, and which must not slow down iteration speed.

This commit restructures it so that the main loop lives in libfuzzer and
directly calls the "test one" function.

In this commit I was a little too aggressive because I made the test
runner export `fuzzer_one` for this purpose. This was motivated by
performance, but it causes "exported symbol collision: fuzzer_one" to
occur when more than one fuzz test is provided.

There are three ways to solve this:

1. libfuzzer needs to be passed a function pointer instead. Possible
   performance downside.

2. build runner needs to build a different process per fuzz test.
   Potentially wasteful and unclear how to isolate them.

3. test runner needs to perform a relocation at runtime to point the
   function call to the relevant unit test. Portability issues and
   dubious performance gains.
solves the problem presented in the previous commit message
This value is useful to help determine run uniqueness in the face of
recursion, however it is not valuable to expose to the fuzzing UI.
@andrewrk andrewrk merged commit eccd06f into master Sep 12, 2024
10 checks passed
@andrewrk andrewrk deleted the fuzz branch September 12, 2024 06:41
Organ1sm added a commit to Organ1sm/arocc that referenced this pull request Sep 17, 2024
Organ1sm added a commit to Organ1sm/arocc that referenced this pull request Sep 20, 2024
DivergentClouds pushed a commit to DivergentClouds/zig that referenced this pull request Sep 24, 2024
rework fuzzing API to accept a function pointer parameter
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.

1 participant