google / oss-fuzz

OSS-Fuzz - continuous fuzzing for open source software.
https://google.github.io/oss-fuzz
Apache License 2.0
10.15k stars 2.16k forks source link

[envoy] fix clang18 libclang_rt linkage issue #11980

Closed adisuissa closed 1 month ago

adisuissa commented 1 month ago

Envoy's UBSAN build current fails with the following error:

ERROR: /src/envoy/test/common/router/BUILD:233:21: Linking test/common/router/config_impl_test_static failed: (Exit 1): clang-18 failed: error executing command (from target //test/common/router:config_impl_test_static) 
Step #23 - "compile-libfuzzer-undefined-x86_64":   (cd /root/.cache/bazel/_bazel_root/4e9824db8e7d11820cfa25090ed4ed10/execroot/envoy && \
Step #23 - "compile-libfuzzer-undefined-x86_64":   exec env - \
Step #23 - "compile-libfuzzer-undefined-x86_64":     BAZEL_COMPILER=clang \
Step #23 - "compile-libfuzzer-undefined-x86_64":     BAZEL_CXXOPTS='-stdlib=libc++' \
Step #23 - "compile-libfuzzer-undefined-x86_64":     BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a \
Step #23 - "compile-libfuzzer-undefined-x86_64":     BAZEL_LINKOPTS=-lm:-pthread \
Step #23 - "compile-libfuzzer-undefined-x86_64":     CC=clang \
Step #23 - "compile-libfuzzer-undefined-x86_64":     CXX=clang++ \
Step #23 - "compile-libfuzzer-undefined-x86_64":     CXXFLAGS='-stdlib=libc++' \
Step #23 - "compile-libfuzzer-undefined-x86_64":     FUZZINTRO_OUTDIR=/src \
Step #23 - "compile-libfuzzer-undefined-x86_64":     LDFLAGS='-stdlib=libc++' \
Step #23 - "compile-libfuzzer-undefined-x86_64":     PATH=/bin:/usr/bin:/usr/local/bin \
Step #23 - "compile-libfuzzer-undefined-x86_64":     PWD=/proc/self/cwd \
Step #23 - "compile-libfuzzer-undefined-x86_64":   /usr/local/bin/clang-18 @bazel-out/k8-fastbuild-ST-0a6de8256f3b/bin/test/common/router/config_impl_test_static-2.params)
Step #23 - "compile-libfuzzer-undefined-x86_64": # Configuration: bcd0434cd1f68317f811560892076634a5706878d94e6459b56108eb78a3a66e
Step #23 - "compile-libfuzzer-undefined-x86_64": # Execution platform: @local_config_platform//:host
Step #23 - "compile-libfuzzer-undefined-x86_64": ld.lld: error: undefined symbol: __ubsan_vptr_type_cache
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced by socket_interface.h:69 (./envoy/network/socket_interface.h:69)
Step #23 - "compile-libfuzzer-undefined-x86_64": >>>               bazel-out/k8-fastbuild-ST-0a6de8256f3b/bin/test/common/router/_objs/config_impl_test_lib/config_impl_test.pic.o:(Envoy::Network::ioHandleForAddr(Envoy::Network::Socket::Type, std::__1::shared_ptr<Envoy::Network::Address::Instance const>, Envoy::Network::SocketCreationOptions const&))
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced by shared_ptr.h:772 (/usr/local/bin/../include/c++/v1/__memory/shared_ptr.h:772)
Step #23 - "compile-libfuzzer-undefined-x86_64": >>>               bazel-out/k8-fastbuild-ST-0a6de8256f3b/bin/test/common/router/_objs/config_impl_test_lib/config_impl_test.pic.o:(Envoy::Network::ioHandleForAddr(Envoy::Network::Socket::Type, std::__1::shared_ptr<Envoy::Network::Address::Instance const>, Envoy::Network::SocketCreationOptions const&))
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced by gtest-internal.h:532 (external/com_google_googletest/googletest/include/gtest/internal/gtest-internal.h:532)
Step #23 - "compile-libfuzzer-undefined-x86_64": >>>               bazel-out/k8-fastbuild-ST-0a6de8256f3b/bin/test/common/router/_objs/config_impl_test_lib/config_impl_test.pic.o:(testing::internal::SuiteApiResolver<Envoy::Router::(anonymous namespace)::RouteMatcherTest>::GetSetUpCaseOrSuite(char const*, int))
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced 174998 more times
Step #23 - "compile-libfuzzer-undefined-x86_64": 
Step #23 - "compile-libfuzzer-undefined-x86_64": ld.lld: error: undefined symbol: __ubsan_handle_dynamic_type_cache_miss_abort
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced by socket_interface.h:69 (./envoy/network/socket_interface.h:69)
Step #23 - "compile-libfuzzer-undefined-x86_64": >>>               bazel-out/k8-fastbuild-ST-0a6de8256f3b/bin/test/common/router/_objs/config_impl_test_lib/config_impl_test.pic.o:(Envoy::Network::ioHandleForAddr(Envoy::Network::Socket::Type, std::__1::shared_ptr<Envoy::Network::Address::Instance const>, Envoy::Network::SocketCreationOptions const&))
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced by socket_interface.h:69 (./envoy/network/socket_interface.h:69)
Step #23 - "compile-libfuzzer-undefined-x86_64": >>>               bazel-out/k8-fastbuild-ST-0a6de8256f3b/bin/test/common/router/_objs/config_impl_test_lib/config_impl_test.pic.o:(Envoy::Network::ioHandleForAddr(Envoy::Network::Socket::Type, std::__1::shared_ptr<Envoy::Network::Address::Instance const>, Envoy::Network::SocketCreationOptions const&))
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced by shared_ptr.h:772 (/usr/local/bin/../include/c++/v1/__memory/shared_ptr.h:772)
Step #23 - "compile-libfuzzer-undefined-x86_64": >>>               bazel-out/k8-fastbuild-ST-0a6de8256f3b/bin/test/common/router/_objs/config_impl_test_lib/config_impl_test.pic.o:(Envoy::Network::ioHandleForAddr(Envoy::Network::Socket::Type, std::__1::shared_ptr<Envoy::Network::Address::Instance const>, Envoy::Network::SocketCreationOptions const&))
Step #23 - "compile-libfuzzer-undefined-x86_64": >>> referenced 244906 more times

Further debugging revealed that the upgrade to clang18 caused the breakage, due to different libclang_rt library file name. This PR fixes this issue.

github-actions[bot] commented 1 month ago

adisuissa is either the primary contact or is in the CCs list of projects/envoy.
adisuissa has previously contributed to projects/envoy. The previous PR was #11921

kleisauke commented 1 month ago

Looks like other projects need something similar too: https://github.com/search?q=repo%3Agoogle%2Foss-fuzz%20libclang_rt.ubsan_standalone_cxx&type=code

adisuissa commented 1 month ago

Looks like other projects need something similar too: https://github.com/search?q=repo%3Agoogle%2Foss-fuzz%20libclang_rt.ubsan_standalone_cxx&type=code

When I looked at the build logs of some of these projects, it seemed that something else was broken.