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

infra: Fix jvm coverage report #12694

Merged

Conversation

arthurscchan
Copy link
Contributor

@arthurscchan arthurscchan commented Nov 6, 2024

The current JVM coverage calculation includes all class files and JAR files in $OUT. If the project has copied necessary dependency JAR files to $OUT for fuzzing purposes, those classes will also be included in the JaCoCo coverage report, adding noise. This PR addresses that issue by only copying class files located in the $OUT/$SRC directory, which are lively compiled from the project source code, ensuring that only project classes are used by jacoco-cli to generate the coverage report. As all JVM languages compile to class files, this approach should work for all JVM languages supported by OSS-Fuzz in general.

@DavidKorczynski DavidKorczynski marked this pull request as ready for review November 13, 2024 22:15
@DavidKorczynski
Copy link
Collaborator

/gcbrun trial_build.py jvm --fuzzing-engines libfuzzer --sanitizers coverage

classes_dir=$DUMPS_DIR/classes
mkdir $classes_dir
for fuzz_target in $FUZZ_TARGETS; do
# Continue if not a fuzz target.
if [[ $FUZZING_ENGINE != "none" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

why delete if [[ $FUZZING_ENGINE != "none" ]]; then? We don't need this logic still?

@DavidKorczynski
Copy link
Collaborator

/gcbrun trial_build.py jvm --fuzzing-engines libfuzzer --sanitizers coverage

@DavidKorczynski
Copy link
Collaborator

/gcbrun trial_build.py jvm --fuzzing-engines libfuzzer --sanitizers coverage

1 similar comment
@DavidKorczynski
Copy link
Collaborator

/gcbrun trial_build.py jvm --fuzzing-engines libfuzzer --sanitizers coverage

@DavidKorczynski
Copy link
Collaborator

The trial build is failing for some reason, and I can't reproduce:

Step #1: Step #2: #20 3.003 Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.003 Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libicu66 amd64 66.1-2ubuntu2.1 [8515 kB]
Step #1: Step #2: #20 3.053 Err:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-0 amd64 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.053   404  Not Found [IP: 91.189.91.83 80]
Step #1: Step #2: #20 3.324 Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libxml2 amd64 2.9.10+dfsg-5ubuntu0.20.04.7 [640 kB]
Step #1: Step #2: #20 3.332 Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 shared-mime-info amd64 1.15-1 [430 kB]
Step #1: Step #2: #20 3.336 Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 xdg-user-dirs amd64 0.17-2ubuntu1 [48.3 kB]
Step #1: Step #2: #20 3.336 Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 libiberty-dev amd64 20200409-1 [142 kB]
Step #1: Step #2: #20 3.338 Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libunwind8 amd64 1.2.1-9ubuntu0.1 [47.7 kB]
Step #1: Step #2: #20 3.338 Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 liblzma-dev amd64 5.2.4-1ubuntu1.1 [147 kB]
Step #1: Step #2: #20 3.340 Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libunwind-dev amd64 1.2.1-9ubuntu0.1 [472 kB]
Step #1: Step #2: #20 3.345 Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 pkg-config amd64 0.29.1-0ubuntu4 [45.5 kB]
Step #1: Step #2: #20 3.346 Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.5 [155 kB]
Step #1: Step #2: #20 3.364 Get:13 http://archive.ubuntu.com/ubuntu focal/universe amd64 libblocksruntime0 amd64 0.4.1-1.1 [6412 B]
Step #1: Step #2: #20 3.395 Get:14 http://archive.ubuntu.com/ubuntu focal/universe amd64 libblocksruntime-dev amd64 0.4.1-1.1 [6806 B]
Step #1: Step #2: #20 3.395 Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.427 Ign:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.457 Err:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.457   404  Not Found [IP: 91.189.91.83 80]
Step #1: Step #2: #20 3.464 E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/glib2.0/libglib2.0-0_2.64.6-1~ubuntu20.04.7_amd64.deb  404  Not Found [IP: 91.189.91.83 80]
Step #1: Step #2: #20 3.464 E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/glib2.0/libglib2.0-data_2.64.6-1~ubuntu20.04.7_all.deb  404  Not Found [IP: 91.189.91.83 80]
Step #1: Step #2: #20 3.464 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Step #1: Step #2: #20 3.464 Fetched 10.7 MB in 1s (18.8 MB/s)
Step #1: Step #2: #20 ERROR: executor failed running [/bin/sh -c precompile_honggfuzz]: exit code: 100
Step #1: Step #2: ------
Step #1: Step #2:  > [14/28] RUN precompile_honggfuzz:
Step #1: Step #2: ------
Step #1: Step #2: executor failed running [/bin/sh -c precompile_honggfuzz]: exit code: 100

@DavidKorczynski
Copy link
Collaborator

/gcbrun trial_build.py jvm --fuzzing-engines libfuzzer --sanitizers coverage

@DavidKorczynski
Copy link
Collaborator

I'm not sure why the trial build fails. It fails when building honggfuzz in the base-builder stage, however, I'm able to build the base builder locally without issues:

Step #1: Step #2: #18 [12/28] RUN cd /src &&     curl -L -O https://github.com/google/honggfuzz/archive/oss-fuzz.tar.gz &&     mkdir honggfuzz &&     cd honggfuzz &&     tar -xz --strip-components=1 -f /src/oss-fuzz.tar.gz &&     rm -rf examples /src/oss-fuzz.tar.gz
Step #1: Step #2: #18 sha256:13849ac059463667edf54664e902c808c02d8b4b8812ce712b197efccd1819fd
Step #1: Step #2: #18 0.373   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Step #1: Step #2: #18 0.373                                  Dload  Upload   Total   Spent    Left  Speed
Step #1: Step #2: #18 0.373 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Step #1: Step #2: #18 1.275 
100 12.6M    0 12.6M    0     0  13.9M      0 --:--:-- --:--:-- --:--:-- 13.9M
100 38.0M    0 38.0M    0     0  20.0M      0 --:--:--  0:00:01 --:--:-- 25.4M
100 60.2M    0 60.2M    0     0  20.7M      0 --:--:--  0:00:02 --:--:-- 23.8M
100 62.2M    0 62.2M    0     0  20.3M      0 --:--:--  0:00:03 --:--:-- 23.0M
Step #1: Step #2: #18 DONE 5.0s
Step #1: Step #2: 
Step #1: Step #2: #19 [13/28] COPY precompile_honggfuzz /usr/local/bin/
Step #1: Step #2: #19 sha256:1134795755e50053a20c533f77265ac74f0cc3d8e4470042364545d3183bda82
Step #1: Step #2: #19 DONE 0.0s
Step #1: Step #2: 
Step #1: Step #2: #20 [14/28] RUN precompile_honggfuzz
Step #1: Step #2: #20 sha256:4442905e96d889821616f4e5e5e0cafc194651a643a3aa5cd71b4f93a05977fe
Step #1: Step #2: #20 0.345 Precompiling honggfuzz
Step #1: 
Step #1: BUILD FAILURE: Build step failure: build step 2 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
Step #1: ERROR: (gcloud.builds.submit) build 1fb67aa6-ef30-4e9f-8452-a713ad866486 completed with status "FAILURE"
Step #1: Step #2: #20 0.398 Reading package lists...
Step #1: Step #2: #20 2.137 Building dependency tree...
Step #1: Step #2: #20 2.445 Reading state information...
Step #1: Step #2: #20 2.784 The following packages were automatically installed and are no longer required:
Step #1: Step #2: #20 2.786   bzip2-doc libncurses-dev libnspr4 libnspr4-dev libnss3
Step #1: Step #2: #20 2.786 Use 'apt autoremove' to remove them.
Step #1: Step #2: #20 2.787 The following additional packages will be installed:
Step #1: Step #2: #20 2.788   libblocksruntime0 libglib2.0-0 libglib2.0-data libicu66 libunwind8 libxml2
Step #1: Step #2: #20 2.788   shared-mime-info xdg-user-dirs
Step #1: Step #2: #20 2.790 Suggested packages:
Step #1: Step #2: #20 2.790   liblzma-doc
Step #1: Step #2: #20 2.873 The following NEW packages will be installed:
Step #1: Step #2: #20 2.873   libblocksruntime-dev libblocksruntime0 libglib2.0-0 libglib2.0-data
Step #1: Step #2: #20 2.875   libiberty-dev libicu66 liblzma-dev libunwind-dev libunwind8 libxml2
Step #1: Step #2: #20 2.875   pkg-config shared-mime-info xdg-user-dirs zlib1g-dev
Step #1: Step #2: #20 2.967 0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.
Step #1: Step #2: #20 2.967 Need to get 12.0 MB of archives.
Step #1: Step #2: #20 2.967 After this operation, 49.5 MB of additional disk space will be used.
Step #1: Step #2: #20 2.967 Ign:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-0 amd64 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.004 Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.004 Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libicu66 amd64 66.1-2ubuntu2.1 [8515 kB]
Step #1: Step #2: #20 3.206 Err:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-0 amd64 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.206   404  Not Found [IP: 91.189.91.82 80]
Step #1: Step #2: #20 3.320 Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libxml2 amd64 2.9.10+dfsg-5ubuntu0.20.04.7 [640 kB]
Step #1: Step #2: #20 3.327 Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 shared-mime-info amd64 1.15-1 [430 kB]
Step #1: Step #2: #20 3.331 Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 xdg-user-dirs amd64 0.17-2ubuntu1 [48.3 kB]
Step #1: Step #2: #20 3.331 Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 libiberty-dev amd64 20200409-1 [142 kB]
Step #1: Step #2: #20 3.333 Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libunwind8 amd64 1.2.1-9ubuntu0.1 [47.7 kB]
Step #1: Step #2: #20 3.333 Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 liblzma-dev amd64 5.2.4-1ubuntu1.1 [147 kB]
Step #1: Step #2: #20 3.335 Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libunwind-dev amd64 1.2.1-9ubuntu0.1 [472 kB]
Step #1: Step #2: #20 3.340 Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 pkg-config amd64 0.29.1-0ubuntu4 [45.5 kB]
Step #1: Step #2: #20 3.341 Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.5 [155 kB]
Step #1: Step #2: #20 3.351 Get:13 http://archive.ubuntu.com/ubuntu focal/universe amd64 libblocksruntime0 amd64 0.4.1-1.1 [6412 B]
Step #1: Step #2: #20 3.382 Get:14 http://archive.ubuntu.com/ubuntu focal/universe amd64 libblocksruntime-dev amd64 0.4.1-1.1 [6806 B]
Step #1: Step #2: #20 3.382 Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.493 Ign:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.604 Err:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.7
Step #1: Step #2: #20 3.604   404  Not Found [IP: 91.189.91.82 80]
Step #1: Step #2: #20 3.610 E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/glib2.0/libglib2.0-0_2.64.6-1~ubuntu20.04.7_amd64.deb  404  Not Found [IP: 91.189.91.82 80]
Step #1: Step #2: #20 3.610 E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/glib2.0/libglib2.0-data_2.64.6-1~ubuntu20.04.7_all.deb  404  Not Found [IP: 91.189.91.82 80]
Step #1: Step #2: #20 3.610 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Step #1: Step #2: #20 3.610 Fetched 10.7 MB in 1s (14.9 MB/s)
Step #1: Step #2: #20 ERROR: executor failed running [/bin/sh -c precompile_honggfuzz]: exit code: 100
Step #1: Step #2: ------
Step #1: Step #2:  > [14/28] RUN precompile_honggfuzz:
Step #1: Step #2: ------
Step #1: Step #2: executor failed running [/bin/sh -c precompile_honggfuzz]: exit code: 100
Step #1: Finished Step #2
Step #1: ERROR
Step #1: ERROR: build step 2 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
Step #1: --------------------------------------------------------------------------------

@maflcko
Copy link
Contributor

maflcko commented Dec 3, 2024

Fix in #12807

@DavidKorczynski
Copy link
Collaborator

/gcbrun trial_build.py jvm --fuzzing-engines libfuzzer --sanitizers coverage

Copy link
Collaborator

@DavidKorczynski DavidKorczynski left a comment

Choose a reason for hiding this comment

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

The only project failing the trial build is not due to this PR.

@DavidKorczynski DavidKorczynski merged commit 8bc2e0b into google:master Dec 4, 2024
18 of 19 checks passed
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.

3 participants