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

cmake: Add fuzzing facilities #43

Merged
merged 2 commits into from
Jan 25, 2024
Merged

cmake: Add fuzzing facilities #43

merged 2 commits into from
Jan 25, 2024

Conversation

hebasto
Copy link
Owner

@hebasto hebasto commented Nov 4, 2023

New CMake variables that affect the build system configuration:

  • SANITIZERS
  • BUILD_FUZZ_BINARY
  • FUZZ

In the light of bitcoin#29189, this PR is no longer based on #41. However, the test/fuzz/script_bitcoin_consensus.cpp might be easily added anytime.

For OSS-Fuzz integration, please refer to hebasto/oss-fuzz#1.

@hebasto
Copy link
Owner Author

hebasto commented Nov 4, 2023

@dergoegge

You might be interested in this PR :)

@dergoegge
Copy link

I'm pretty sure we will need the equivalent of SANITIZER_LDFLAGS for our oss-fuzz builds: https://github.com/google/oss-fuzz/blob/876d043e5595966bfaca51f39be017d58bb732c5/projects/bitcoin-core/build.sh#L57

@hebasto
Copy link
Owner Author

hebasto commented Nov 7, 2023

Rebased.

@hebasto
Copy link
Owner Author

hebasto commented Nov 9, 2023

Rebased and updated.

@hebasto
Copy link
Owner Author

hebasto commented Nov 16, 2023

Rebased.

@hebasto
Copy link
Owner Author

hebasto commented Dec 6, 2023

Rebased.

@hebasto
Copy link
Owner Author

hebasto commented Dec 11, 2023

Rebased.

@theuni
Copy link

theuni commented Dec 15, 2023

Ping @fanquake re sanitizers. I'm curious if you think we should drop support for forwarding those flags as well.

Copy link

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @fanquake re sanitizers. I'm curious if you think we should drop support for forwarding those flags as well.

@theuni what do you mean re forwarding flags here?

CMakeLists.txt Outdated Show resolved Hide resolved
@hebasto hebasto marked this pull request as ready for review January 7, 2024 19:12
@hebasto
Copy link
Owner Author

hebasto commented Jan 7, 2024

  1. Rebased.
  2. Description has been updated.
  3. Addressed @dergoegge's and @fanquake's comments.

This PR is ready for review now.

Friendly ping @dergoegge @maflcko @fanquake @TheCharlatan @theuni :)

@@ -72,6 +72,26 @@ tristate_option(WITH_USDT

option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
cmake_dependent_option(BUILD_FUZZ_BINARY "Build fuzz binary." ON "NOT MSVC" OFF)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers because I had to look up this syntax again. This does the obvious thing: If not msvc, provide the BUILD_FUZZ_BINARY option and set it to ON by default.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -72,6 +72,26 @@ tristate_option(WITH_USDT

option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
cmake_dependent_option(BUILD_FUZZ_BINARY "Build fuzz binary." ON "NOT MSVC" OFF)
cmake_dependent_option(FUZZ "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one means: If not msvc, provide the FUZZ option and set it to OFF by default.

src/test/fuzz/CMakeLists.txt Show resolved Hide resolved
src/test/fuzz/CMakeLists.txt Outdated Show resolved Hide resolved
@hebasto
Copy link
Owner Author

hebasto commented Jan 9, 2024

Rebased.

@dergoegge
Copy link

Tested the oss-fuzz builds for libfuzzer and afl++, looking good!

@hebasto
Copy link
Owner Author

hebasto commented Jan 16, 2024

Rebased.

@hebasto
Copy link
Owner Author

hebasto commented Jan 19, 2024

As it was requested during yesterday's meeting, the google/oss-fuzz#11516 has been submitted on testing purposes.

UPD. See hebasto/oss-fuzz#1.

@hebasto
Copy link
Owner Author

hebasto commented Jan 19, 2024

As it was requested during yesterday's meeting, the google/oss-fuzz#11516 has been submitted on testing purposes.

UPD. See hebasto/oss-fuzz#1.

https://github.com/hebasto/oss-fuzz/actions/runs/7585104640 is 🟢 :)

Copy link

@theuni theuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lightly tested ACK 9b9f562.

I went through the deps to see if anything could be scoped more minimally, but it seems what's here is correct.

@hebasto hebasto merged commit 3659fca into cmake-staging Jan 25, 2024
22 checks passed
hebasto added a commit that referenced this pull request Jan 29, 2024
63c1bb5 fixup! cmake: Add fuzzing options (Hennadii Stepanov)
d31abc2 fixup! ci: Test CMake edge cases (Hennadii Stepanov)

Pull request description:

  From #85 (comment):
  > **Known Bugs**
  >
  > Unfortunately, due to a silent conflict between #43 and #77, providing `-DFUZZ=ON` does not disable the `bitcoin-qt` target. It will be fixed shortly after pushing this branch.

  Fixed.

ACKs for top commit:
  vasild:
    ACK 63c1bb5

Tree-SHA512: b3cc2889d0239913de64c170880c97b37966a890d8c4e05f9090485a016b7f9cdf4880d770a234f323d3191b9adda8ed0343c29dfa49b5bb99b0b54481d4335e
@dergoegge
Copy link

I think we forgot to update the fuzzing docs https://github.com/hebasto/bitcoin/blob/cmake-staging/doc/fuzzing.md

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.

4 participants