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

Add support for Ubuntu 20.04 LTS (where OSS-Fuzz is at) #274

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

hartwork
Copy link
Contributor

@hartwork hartwork commented Feb 19, 2025

OSS-Fuzz is using Ubuntu 20.04. This pull request will help unlock use of libprotobuf-mutator in OSS-Fuzz with system Protobuf (i.e. of Ubuntu >=20.04) and eventually allow re-enabling compilation of libexpat upstream fuzzer xml_lpm_fuzzer that pull request libexpat/libexpat#955 had to disable for a chance at a successful build in OSS-Fuzz. Thank you! 🙏

CC @vitalybuka

@hartwork hartwork requested a review from vitalybuka as a code owner February 19, 2025 01:06
@hartwork
Copy link
Contributor Author

hartwork commented Feb 19, 2025

@vitalybuka any thoughts? I understand that Ubuntu 20.04 is on its way out — both in GitHub Actions and its life with support by Canonical — and that therefore in other places support for Ubuntu 20.04 is rather removed than added. However OSS-Fuzz will take more time to perform a non-trivial migration off of Ubuntu 20.04 that affects all OSS-Fuzz projects at once, so I personally believe that it's a viable short-term strategy to first increase support for the past, and to then take it away again once OSS-Fuzz had time to move. I am happy to create a second (trivial) pull request dropping Ubuntu 20.04 from CI again once GitHub Actions pulled the plug and then a third (trivial) pull request reverting 4 of the commits supporting less recent Protobuf to clean the code again once OSS-Fuzz is off of Ubuntu "focal" 20.04 for good. What do you think?

PS: Review on commit level will be most enjoyable here.

@hartwork hartwork force-pushed the ubuntu-20-04-support branch from 8a5ffb2 to 46cc89f Compare February 19, 2025 23:20
@@ -40,6 +40,16 @@ jobs:
c_compiler: clang
cpp_compiler: clang++
bundled_protobuf: 'OFF'
- os: ubuntu-20.04
build_type: Release
c_compiler: clang-12
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is default compiler there?

Copy link
Contributor Author

@hartwork hartwork Feb 19, 2025

Choose a reason for hiding this comment

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

@vitalybuka Clang 11 from focal-updates. Ubuntu 20.04 natively has clang-10 and clang-12 from "focal" and clang-11 from "focal-updates":

README.md Outdated
@@ -8,6 +8,14 @@ libprotobuf-mutator is a library to randomly mutate
[protobuffers](https://github.com/google/protobuf). <BR>
It could be used together with guided fuzzing engines, such as [libFuzzer](http://libfuzzer.info).

The core of libprotobuf-mutator has the following dependencies:

- CMake >=3.10
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@hartwork hartwork Feb 19, 2025

Choose a reason for hiding this comment

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

can we avoid adding another place which can get out of sync?

@vitalybuka it would not be fun to dig out that info as a user when needed, and the damage of these going out of sync is minimal. The reason I'm adding it is because this info is not documented anywhere. I can drop the part on CMake if it takes to much attention, Clang and Protobuf are key here.

Maybe https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet

These links would continue working but also go stale and not gain anything.

Copy link
Collaborator

Choose a reason for hiding this comment

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

User will hit error if something is out of date. And then see Cmake condition.
I don't think anyone will start from documentation either before seeing error, or after seeing error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vitalybuka I'm reading that as a wish to drop CMake versions from this. Dropped and pushed.

port/protobuf.h Outdated
// clang-format off
#include "google/protobuf/port_def.inc" // MUST be last header included
# include "google/protobuf/port_def.inc" // MUST be last header included
Copy link
Collaborator

Choose a reason for hiding this comment

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

I though we need this for PROTOBUF_VERSION
if we switch to GOOGLE_PROTOBUF_VERSION, can we drop this include?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vitalybuka I don't know. I can drop it, throw it at the CI and see if it sticks. Protobuf examples want us to add it though, so we should probably keep it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vitalybuka PS: I confirm that offering PROTOBUF_VERSION is one of the effects of that include, yes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

what kind of examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vitalybuka seems like I mis-remembered the headers own usage instructions at https://github.com/protocolbuffers/protobuf/blob/7229ef1b4f0f975036b140fe71c76d25feff4918/src/google/protobuf/port_def.inc#L19-L23 as a tutorial. I cannot find other places promoting it. Let me query CI for a version without it…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I though we need this for PROTOBUF_VERSION if we switch to GOOGLE_PROTOBUF_VERSION, can we drop this include?

@vitalybuka dropped and pushed now

@@ -678,12 +678,23 @@ TYPED_TEST(MutatorTypedTest, Serialization) {
}

TYPED_TEST(MutatorTypedTest, UnknownFieldTextFormat) {
// NOTE: This test has little chance of passing when method
// TextFormat::Parser::AllowUnknownField is not available
#if GOOGLE_PROTOBUF_VERSION >= 3008000 // commit 176f7db11d8242b36a3ea6abb1cc436fca5bf75d of >=3.8.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need before 3.8.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hartwork hartwork force-pushed the ubuntu-20-04-support branch from 46cc89f to 3156448 Compare February 19, 2025 23:43
There are two Protobuf version macros: GOOGLE_PROTOBUF_VERSION and
PROTOBUF_VERSION without the "GOOGLE_" prefix.  Both ancient
and recent only expose macro GOOGLE_PROTOBUF_VERSION with the "GOOGLE_"
prefix but not the other, so we depart from PROTOBUF_VERSION.

Motivation for this change was that headers port_def.inc and
port_undef.inc were only introduced to Protobuf in commit
6bbe197e9c1b6fc38cbdc45e3bf83fa7ced792a3 of release >=3.7.0 while
we want to support Protobuf 3.6.1.3 of Ubuntu 20.04, too.

Signed-off-by: Sebastian Pipping <[email protected]>
Seed 9 was selected after quick experiments with values 1 to 20
for its speed, i.e. low number of runs needed to find the
respective bug in both libfuzzer_example (text) and
libfuzzer_bin_example (binary), combined (i.e. number of runs
added).  It was not a scientifc experiment by any means,
and determinism (rather than speed) is my primary goal here.

Signed-off-by: Sebastian Pipping <[email protected]>
.. to ease future debugging

Signed-off-by: Sebastian Pipping <[email protected]>
.. now that the fixed seed makes that safe to do

Signed-off-by: Sebastian Pipping <[email protected]>
.. while allowing to build the core project with CMake 3.10.

Signed-off-by: Sebastian Pipping <[email protected]>
@hartwork hartwork force-pushed the ubuntu-20-04-support branch from 3156448 to 561cd60 Compare February 20, 2025 00:10
@hartwork hartwork requested a review from vitalybuka February 20, 2025 00:10
@hartwork
Copy link
Contributor Author

@vitalybuka update: I have all remaining pieces figured out now, OSS-Fuzz CI for google/oss-fuzz#13015 is also green just now including i386, it just needs one commit reverted from a custom branch back to mainline and we're good to go… once this pull request here is merged to master. Does it need any more adjustments from your point of view? Thanks! 🙏

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.

2 participants