-
Notifications
You must be signed in to change notification settings - Fork 37.7k
tests: Provide main(...) function in fuzzer. Allow building uninstrumented harnesses with --enable-fuzz. #19366
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
tests: Provide main(...) function in fuzzer. Allow building uninstrumented harnesses with --enable-fuzz. #19366
Conversation
The Reported as #19369. |
@sipa @theuni I think this is in reply to the recent IRC conversation? For reference:
|
I'd say they should be compiled by default, just like bench and the unit tests, and the gui, and the gui tests. No one is running the benchmarks to do actual benchmarking in a usual development workflow. They are merely compiled to be smoke-run once in Similar to The reason that fuzz tests are handled differently is because I am lacking the background in automake to do even the most simplest task. (I leave improvements in the build system for others to implement. E.g. #18527 😬 ) Anyway, I think all the tests should be handled the same by the build system and |
Concept ACK. I think we'd want to skip building them in gitian (to save time for every platform, the result isn't shipped), but for a normal developer build it'd make sense. |
Jup, I think gitian/guix set |
@MarcoFalke I hadn't seen that conversation (I'm not on IRC), so this PR isn't a reply to it :) I've simply needed this myself many times when using the fuzzing harnesses as simple application entry points for concolic testing tools, abstract interpretation static analysis tools, etc which analyze the possible execution flow from In other words, being able to build the fuzz targets (non-instrumented using This PR is restoring how things worked under Linux prior to the "macOS libFuzzer linker issue" fixed in #18008 (I'm upstreaming a local fix I've had for this). Regarding the quoted IRC conversation: I fully agree that we should start building the fuzzing harnesses by default, but I think that is largely unrelated to this PR. FWIW, the coverage of the fuzzing harnesses is quickly approaching the coverage reached by the unit tests (see unit test coverage and fuzz test coverage). Hopefully writing fuzz tests to show a basic level of robustness for new code will soon be almost as natural as writing unit or functional tests for new code :) Building the fuzzers by default will hopefully help us get there even sooner. |
review ACK fdb933c |
fdb933c
to
1087807
Compare
ACK 1087807 |
Post-merge Concept ACK.
I agree. This may catch a number of inadvertent fuzz build issues we've been seeing in PRs. |
Summary: This makes it possible to build with libfuzzer on macOS ([[bitcoin/bitcoin#18008 | PR18008]]), fix the issue that this PR introduced for other platforms ([[bitcoin/bitcoin#19366 | PR19366]]) and add the corresponding documentation ([[bitcoin/bitcoin#17942 | PR17942]]). This is a backport of core [[bitcoin/bitcoin#17942 | PR17942]], [[bitcoin/bitcoin#18008 | PR18008]] and [[bitcoin/bitcoin#19366 | PR19366]]. Test Plan: On macOS, read the documentation and follow the instructions. I only ran the instructions for libfuzzer. ninja bitcoin-fuzzers ./test/fuzz/test_runner.py <path_to_corpus> Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D8956
…ow building uninstrumented harnesses with --enable-fuzz. 1087807 tests: Provide main(...) function in fuzzer (practicalswift) Pull request description: Provide `main(...)` function in fuzzer. Allow building uninstrumented harnesses with only `--enable-fuzz`. This PR restores the behaviour to how things worked prior to bitcoin#18008. bitcoin#18008 worked around an macOS specific issue but did it in a way which unnecessarily affected platforms not in need of the workaround :) Before this patch: ``` # Build uninstrumented fuzzing harness (no libFuzzer/AFL/other-fuzzer-instrumentation) $ ./configure --enable-fuzz $ make CXXLD test/fuzz/span /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status Makefile:7244: recipe for target 'test/fuzz/span' failed make[2]: *** [test/fuzz/span] Error 1 make[2]: *** Waiting for unfinished jobs.... $ ``` After this patch: ``` # Build uninstrumented fuzzing harness (no libFuzzer/AFL/other-fuzzer-instrumentation) $ ./configure --enable-fuzz $ make $ echo foo | src/test/fuzz/span $ ``` The examples above show the change in non-macOS functionality. macOS functionality is unaffected by this patch. ACKs for top commit: MarcoFalke: ACK 1087807 Tree-SHA512: 9c16ea32ffd378057c4fae9d9124636d11e3769374d340f68a1b761b9e3e3b8a33579e60425293c96b8911405d8b96ac3ed378e669ea4c47836af06892aca73d
Provide
main(...)
function in fuzzer. Allow building uninstrumented harnesses with only--enable-fuzz
.This PR restores the behaviour to how things worked prior to #18008. #18008 worked around an macOS specific issue but did it in a way which unnecessarily affected platforms not in need of the workaround :)
Before this patch:
After this patch:
The examples above show the change in non-macOS functionality. macOS functionality is unaffected by this patch.