oss-fuzz icon indicating copy to clipboard operation
oss-fuzz copied to clipboard

[Solidity] Build failure due to system linker

Open bshastry opened this issue 2 years ago • 9 comments

For the proto fuzzers, the following failure happens. This is unrelated to upstream project.

/usr/bin/ld.gold: internal error in read_header_prolog, at ../../gold/dwarf_reader.cc:1678
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea why?

bshastry avatar May 04 '23 10:05 bshastry

Nope. I don't think we made any changes recently and other projects do not appear affected.

jonathanmetzman avatar May 05 '23 10:05 jonathanmetzman

I think we need to adjust similar to the following commit, which seems to have missed solidity https://github.com/google/oss-fuzz/commit/a455e651de867eb7aed4c351b424d1d9538f4e50 (issue: https://github.com/google/oss-fuzz/issues/10161) -- I'll give it a try and update here

DavidKorczynski avatar May 05 '23 12:05 DavidKorczynski

I'll give it a try and update here

It's probably easier for you @bshastry as it looks to be deeper in the solidity build systems (https://github.com/ethereum/solidity/blob/a00a2117c5aceb9c77e4e970196f3208ed1ea25c/test/tools/ossfuzz/CMakeLists.txt#L67-L70 ?) in either case, the above commit and issue should clarify why the protobuf fuzzers started failing and how to fix it.

DavidKorczynski avatar May 05 '23 12:05 DavidKorczynski

Thank you so much. Here's my understanding of the breaking change and the fix. Please correct me if I'm wrong

  1. LPM downgraded from ~~c++14~~ c++17 to ~~c++17~~c++14. This somehow required protobuf libraries to be linked together and not in arbitrary order as was the case before.

  2. Upstream projects that make use of protobuf fuzzers hence need to respect this linker grouping.

Solidity makes use of c++17. Would this be a problem?

bshastry avatar May 06 '23 09:05 bshastry

Solidity makes use of c++17. Would this be a problem?

@vitalybuka could you assist here?

DavidKorczynski avatar May 07 '23 12:05 DavidKorczynski

I'll give it a try and update here

It's probably easier for you @bshastry as it looks to be deeper in the solidity build systems (https://github.com/ethereum/solidity/blob/a00a2117c5aceb9c77e4e970196f3208ed1ea25c/test/tools/ossfuzz/CMakeLists.txt#L67-L70 ?) in either case, the above commit and issue should clarify why the protobuf fuzzers started failing and how to fix it.

Sadly, the suggested fix does not work. FWIW, I'm linking an address sanitized c++17 build of solidity. Error is same as in original post.

bshastry avatar May 08 '23 08:05 bshastry

The only "fix" I've been able to come up with so far to get the protobuf fuzzers to build is to use the LPM commit prior to the breaking change (specifically this commit: https://github.com/google/libprotobuf-mutator/commit/212a7be1eb08e7f9c79732d2aab9b2097085d936)

bshastry avatar May 08 '23 10:05 bshastry

Could you please let me know how to fix this cleanly. For now, I've created a PR to use a hard-coded commit (prior to the LP upgrade, see https://github.com/google/oss-fuzz/pull/10301) that does not fail the solidity build. Adding the -Wl --start-group, -lprotobuf --Wl --end-group to the linker options does not work unfortunately.

bshastry avatar May 11 '23 08:05 bshastry

We are also experiencing this issue in the @ImageMagick introspector build when we build one of our dependencies. Any tips on how we can figure out what is causing that?

dlemstra avatar May 05 '24 13:05 dlemstra

I think the current solidity error is:

Step #6 - "compile-libfuzzer-introspector-x86_64": clang-15: [0;1;31merror: [0m[1munable to execute command: Segmentation fault (core dumped)[0m

Possibly (I haven't tried), it can be fixed by bumping the compiler version via:

diff --git a/projects/solidity/Dockerfile b/projects/solidity/Dockerfile
index 52952b0ee..2932992d9 100644
--- a/projects/solidity/Dockerfile
+++ b/projects/solidity/Dockerfile
@@ -14,8 +14,7 @@
 #
 ################################################################################
 
-FROM gcr.io/oss-fuzz-base/base-builder@sha256:19782f7fe8092843368894dbc471ce9b30dd6a2813946071a36e8b05f5b1e27e
-# ! This project was pinned after a clang bump. Please remove the pin, Try to fix any build warnings and errors, as well as runtime errors
+FROM gcr.io/oss-fuzz-base/base-builder
 RUN apt-get update && apt-get install -y make autoconf automake libtool \
     build-essential libbz2-dev ninja-build zlib1g-dev wget python python-dev \
     liblzma-dev uuid-dev pkg-config openjdk-8-jdk unzip mlton bison texinfo

maflcko avatar May 06 '24 08:05 maflcko