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

OSS-fuzz build is failing because 'cargo fuzz' fails to build #757

Closed
BurntSushi opened this issue Apr 8, 2021 · 3 comments
Closed

OSS-fuzz build is failing because 'cargo fuzz' fails to build #757

BurntSushi opened this issue Apr 8, 2021 · 3 comments

Comments

@BurntSushi
Copy link
Member

BurntSushi commented Apr 8, 2021

Here's the OSS-fuzz ticket: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32817

Here's the build log: https://oss-fuzz-build-logs.storage.googleapis.com/log-c25752c4-6e8b-4e9c-b09d-0a488f5bb1a9.txt

The relevant section is:

Starting Step #3
Step #3: Already have image: gcr.io/oss-fuzz/rust-regex
Step #3: ---------------------------------------------------------------
Step #3: Compiling libFuzzer to /usr/lib/libFuzzingEngine.a...  done.
Step #3: ---------------------------------------------------------------
Step #3: CC=clang
Step #3: CXX=clang++
Step #3: CFLAGS=-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION  -fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument
Step #3: CXXFLAGS=-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION  -fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument -stdlib=libc++
Step #3: ---------------------------------------------------------------
Step #3: + cd /src/regex
Step #3: + cargo fuzz build -O
Step #3: warning: /src/regex/fuzz/Cargo.toml: use `[profile.dev]` to configure debug builds
Step #3:     Updating crates.io index
Step #3:  Downloading crates ...
Step #3:   Downloaded arbitrary v0.4.7
Step #3:   Downloaded memchr v2.3.4
Step #3:   Downloaded cc v1.0.67
Step #3:   Downloaded libfuzzer-sys v0.3.5
Step #3:   Downloaded aho-corasick v0.7.15
Step #3:    Compiling memchr v2.3.4
Step #3:    Compiling cc v1.0.67
Step #3:    Compiling regex-syntax v0.6.23 (/src/regex/regex-syntax)
Step #3:    Compiling arbitrary v0.4.7
Step #3:    Compiling aho-corasick v0.7.15
Step #3:    Compiling libfuzzer-sys v0.3.5
Step #3: error: symbol `_RINvMNtNtCskrsM4FCwAVA_4core3ptr7mut_ptrOINtNtCs2beRm3ZGvIF_5alloc3vec3VecINtNtBI_5boxed3BoxDNtNtNtNtB7_4iter6traits8iterator8Iteratorp4ItemcEL_EE4castuECs9KydpJjV7w1_9arbitrary` is already defined
Step #3: 
Step #3: error: aborting due to previous error
Step #3: 
Step #3: error: could not compile `arbitrary`
Step #3: 
Step #3: To learn more, run the command again with --verbose.
Step #3: warning: build failed, waiting for other jobs to finish...
Step #3: error: build failed

But when I run cargo fuzz build -O locally, it completes successfully. It would be much appreciated if someone who knows more about OSS-fuzz could help here. I did try to run the Docker image the build appears to be using directly, but it couldn't be found:

$ docker run -it --rm gcr.io/oss-fuzz/rust-regex:latest bash
Unable to find image 'gcr.io/oss-fuzz/rust-regex:latest' locally
docker: Error response from daemon: manifest for gcr.io/oss-fuzz/rust-regex:latest not found: manifest unknown: Failed to fetch "latest" from request "/v2/oss-fuzz/rust-regex/manifests/latest".

cc @DavidKorczynski

@DavidKorczynski
Copy link
Contributor

I think this is because we need to update libfuzzer-sys v0.3.5 to libfuzzer-sys v0.4.0 - give me a few moments to verify

@BurntSushi
Copy link
Member Author

Interesting. When I ran cargo fuzz locally, it does seem to be using 0.3.5 though and it works:

$ cargo fuzz build -O
warning: /home/andrew/rust/regex/fuzz/Cargo.toml: use `[profile.dev]` to configure debug builds
    Updating crates.io index
  Downloaded cc v1.0.67
  Downloaded arbitrary v0.4.7
  Downloaded libfuzzer-sys v0.3.5
  Downloaded 3 crates (192.2 KB) in 0.19s
   Compiling memchr v2.3.4
   Compiling cc v1.0.67
   Compiling arbitrary v0.4.7
   Compiling regex-syntax v0.6.23 (/home/andrew/rust/regex/regex-syntax)
   Compiling aho-corasick v0.7.15
   Compiling libfuzzer-sys v0.3.5
   Compiling regex v1.4.5 (/home/andrew/rust/regex)
   Compiling regex-fuzz v0.0.0 (/home/andrew/rust/regex/fuzz)
    Finished release [optimized + debuginfo] target(s) in 40.02s

But maybe there is some other environment issue that I'm missing. In any case, thank you very much for looking into this!

@DavidKorczynski
Copy link
Contributor

Notice that it is only the coverage build (i.e. python infra/helper.py build_fuzzers --sanitizer=coverage rust-regex) that fails. The other sanitizers work.

I just tested locally and confirm it works with version 0.4.0. Pushed a fix here: #758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants