fuzzer build failure for upx is not debuggable
- Dominant language
- Shell
- Stars
- 12.6k
- Forks
- 2.9k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 61
Description
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66785&q=label%3AProj-upx
The log ends with
```
Step #3 - "compile-afl-address-x86_64": ---------------------------------------------------------------
Step #3 - "compile-afl-address-x86_64": Copying precompiled AFL++
Step #3 - "compile-afl-address-x86_64":
Step #3 - "compile-afl-address-x86_64": AFL++ target compilation setup:
Step #3 - "compile-afl-address-x86_64": AFL_IGNORE_UNKNOWN_ENVS=1
Step #3 - "compile-afl-address-x86_64": AFL_QUIET=1
Step #3 - "compile-afl-address-x86_64": AFL_IGNORE_PROBLEMS=1
Step #3 - "compile-afl-address-x86_64":
Step #3 - "compile-afl-address-x86_64": done.
Step #3 - "compile-afl-address-x86_64": ---------------------------------------------------------------
Step #3 - "compile-afl-address-x86_64": CC=/src/aflplusplus/afl-clang-fast
Step #3 - "compile-afl-address-x86_64": CXX=/src/aflplusplus/afl-clang-fast++
Step #3 - "compile-afl-address-x86_64": CFLAGS=-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope
Step #3 - "compile-afl-address-x86_64": CXXFLAGS=-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -stdlib=libc++
Step #3 - "compile-afl-address-x86_64": RUSTFLAGS=--cfg fuzzing -Zsanitizer=address -Cdebuginfo=1 -Cforce-frame-pointers
Step #3 - "compile-afl-address-x86_64": ---------------------------------------------------------------
Step #3 - "compile-afl-address-x86_64": + sed -i 's/ \&\& __clang_major__ < 15//m' /src/upx/src/util/util.cpp
Step #3 - "compile-afl-address-x86_64": + git apply /src/upx/fuzzers/build.patch
Step #3 - "compile-afl-address-x86_64": error: patch failed: CMakeLists.txt:595
Step #3 - "compile-afl-address-x86_64": error: CMakeLists.txt: patch does not apply
Step #3 - "compile-afl-address-x86_64": ********************************************************************************
Step #3 - "compile-afl-address-x86_64": Failed to build.
Step #3 - "compile-afl-address-x86_64": To reproduce, run:
Step #3 - "compile-afl-address-x86_64": python infra/helper.py build_image upx
Step #3 - "compile-afl-address-x86_64": python infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 upx
Step #3 - "compile-afl-address-x86_64": ********************************************************************************
Finished Step #3 - "compile-afl-address-x86_64"
ERROR
ERROR: build step 3 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
```
and yes, the instructions "To reproduce, run:" do reproduce the error. However, there is little clue about how to fix it. There should be relevant data and suggestions.
If a patch does not apply, then there should be a **.rej** reject file which gives the hunk that failed to apply: a path to the file from filesystem root, the line numbers, the actual pre-patch context in the file, the hunk itself. This information is crucial to understand **why** the patch does not apply.
Looking for a build.patch file:
```
$ find . -name build.patch
./projects/lucene/build.patch
./projects/upx/fuzzers/build.patch
./projects/retrofit/build.patch
./projects/spring-webflow/build.patch
./projects/jxls/build.patch
./build/out/upx/src/upx/fuzzers/build.patch
```
The file `./projects/upx/build.sh`contains the text
```
# Temporary fix for clang bug of upx
sed -i 's/ \&\& __clang_major__ < 15//m' /src/upx/src/util/util.cpp
git apply $SRC/upx/fuzzers/build.patch
```
but what is the meaning of `clang bug of upx` Does upx have a bug, or does clang have a bug, or both? And what is the nature of the bug? Also, the command-line portion `//m` is too cryptic; it should be explained. (`man sed` says nothing about a `m` trailing modifier to the `s` command of **sed**.
Looking at `git blame` of tip of branch `devel` of util/util.cpp:
```
62dbf8485 src/util/util.cpp (Markus F.X.J. Oberhumer 2023-09-04 07:28:48 +0200 279) // much better memswap(), optimized for our use case in sort functions below
718ec468f src/util/util.cpp (Markus F.X.J. Oberhumer 2024-02-02 10:17:16 +0100 280) static void memswap_no_overlap(byte *a, byte *b, size_t n) noexcept {
62dbf8485 src/util/util.cpp (Markus F.X.J. Oberhumer 2023-09-04 07:28:48 +0200 281) #if defined(__clang__) && __clang_major__ < 15
62dbf8485 src/util/util.cpp (Markus F.X.J. Oberhumer 2023-09-04 07:28:48 +0200 282) // work around a clang < 15 ICE (Internal Compiler Error)
632c7c482 src/util/util.cpp (Markus F.X.J. Oberhumer 2023-10-05 03:51:27 +0200 283) // @COMPILER_BUG @CLANG_BUG
bb6b08786 src/util/util.cpp (Markus F.X.J. Oberhumer 2023-09-01 10:49:47 +0200 284) upx_memswap(a, b, n);
```
Perhaps the comment and patch in `./projects/upx/build.sh` is unnecessary?
Anyway, the problem of the fuzzer not building is not the fault of any contents in the source of upx.
Contributor guide
Assessment
This issue has not been assessed yet.