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

Support for LLVM 13 fuzzing #6268

Closed
alexcrichton opened this issue Aug 23, 2021 · 7 comments · Fixed by #6517
Closed

Support for LLVM 13 fuzzing #6268

alexcrichton opened this issue Aug 23, 2021 · 7 comments · Fixed by #6517

Comments

@alexcrichton
Copy link
Contributor

I got a notification that the flate2 project's coverage build is failing and has the error message:

Step #5: warning: /workspace/out/coverage/dumps/fuzz_gz_roundtrip.16218861006045500770_0.profraw: Unsupported instrumentation profile format version
Step #5: error: No profiles could be merged.

AFAIK nothing about flate2 itself has changed, but the most recent change I can think of is that the Rust compiler upgraded to LLVM 13 over the weekend. I suspect that the new LLVM version may have updated something about coverage instrumentation?

@alexcrichton
Copy link
Contributor Author

Also we're seeing a different failure in wasmtime's normal fuzz builds which I believe is mixing C/Rust so I think that there's possibly another incompatibility with LLVM 13, which Rust is using, and the system C compiler perhaps?

@DavidKorczynski
Copy link
Collaborator

Can confirm Rust issues - I get build failures on many (all projects I am CCed on) Rust projects.

@alexcrichton
Copy link
Contributor Author

I'm attempting to pin the Rust toolchain to a pre-LLVM-13 version in #6288 as a temporary fix for now.

@maflcko
Copy link
Contributor

maflcko commented Sep 13, 2021

Is this still an issue?

@catenacyber
Copy link
Contributor

@jonathanmetzman this is still an issue after rolling out clang 14

Reverting to clang13 makes suricata and rustls coverage builds succeed :

Patch is

diff --git a/infra/base-images/base-clang/checkout_build_install_llvm.sh b/infra/base-images/base-clang/checkout_build_install_llvm.sh
index a62b27cf..b4c00ad9 100755
--- a/infra/base-images/base-clang/checkout_build_install_llvm.sh
+++ b/infra/base-images/base-clang/checkout_build_install_llvm.sh
@@ -70,11 +70,11 @@ cd clang
 LLVM_SRC=$SRC/llvm-project
 
 # For manual bumping.
-OUR_LLVM_REVISION=llvmorg-12-init-17251-g6de48655
+OUR_LLVM_REVISION=llvmorg-13.0.0-rc1-gd6974c010878
 
 # To allow for manual downgrades. Set to 0 to use Chrome's clang version (i.e.
 # *not* force a manual downgrade). Set to 1 to force a manual downgrade.
-FORCE_OUR_REVISION=0
+FORCE_OUR_REVISION=1
 LLVM_REVISION=$(grep -Po "CLANG_REVISION = '\K([^']+)" scripts/update.py)
 
 clone_with_retries https://github.com/llvm/llvm-project.git $LLVM_SRC

Test is

python3 infra/helper.py build_image --no-pull base-builder
python3 infra/helper.py build_image --no-pull base-builder-rust
python3 infra/helper.py build_image --no-pull base-runner
python3 infra/helper.py build_image --no-pull suricata
python infra/helper.py build_fuzzers --sanitizer coverage suricata
python infra/helper.py coverage --no-corpus-download suricata

Right now, without this patch, we get malformed instrumentation profile data errors
Before rolling clang-14 we had Unsupported instrumentation profile format version (because rust compiler used clang13 profile format)

Before : https://oss-fuzz-build-logs.storage.googleapis.com/log-3022ca9e-fbae-44d7-ac43-1214b857004b.txt
After : https://oss-fuzz-build-logs.storage.googleapis.com/log-b7dd2a93-58b6-47d2-88ef-7e0c2ffb7bd9.txt

Should we revert to clang 13 ? Only for rust projects ?

@catenacyber
Copy link
Contributor

llvmorg-14-init+ cherry-pick of a6c14fba70e170a279f7e77f068368f09d8c5eaf seems good to me

@catenacyber
Copy link
Contributor

I found the culprit commit in llvm : https://reviews.llvm.org/D104556

catenacyber added a commit to catenacyber/oss-fuzz that referenced this issue Sep 24, 2021
Cf google#6268

Latest clang-14 and clang-13 used by rust or swift have a slightly
different profraw file format

llvm-cov-rel is tool that will update the profraw file produced
by clang-13 to one readable by clang-14 llvm-cov tools
jonathanmetzman pushed a commit that referenced this issue Sep 27, 2021
* coverage: introduces llvm-cov-rel

Cf #6268

Latest clang-14 and clang-13 used by rust or swift have a slightly
different profraw file format

llvm-cov-rel is tool that will update the profraw file produced
by clang-13 to one readable by clang-14 llvm-cov tools

* Suricata as a rust project

* rust coverage: remaps every rust subdirectory in fuzz

So that projects not using default fuzz_targets subdir
get the good remap, and hence the good coverage report
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants