bazel-contrib / rules_fuzzing

Bazel Starlark extensions for defining fuzz tests in Bazel projects
Apache License 2.0
84 stars 20 forks source link

tcmalloc on OSS-Fuzz fails with bazel 6.0.0 #222

Closed DavidKorczynski closed 1 year ago

DavidKorczynski commented 1 year ago

Expected Behavior

OSS-Fuzz builds running without issues. This issue only occurs for tcmalloc on oss-fuzz and no the other projects that use rules_fuzzing.

Actual Behavior

Building tcmalloc with bazel 6.0.0 on OSS-Fuzz fails (https://oss-fuzz-build-logs.storage.googleapis.com/log-16698571-28fb-4b75-97bb-5839f2c15b62.txt):

ERROR: /root/.cache/bazel/_bazel_root/c8255052695dac5944bb165668b0ceed/external/bazel_tools/platforms/BUILD:89:6: in alias rule @bazel_tools//platforms:windows: Constraints from @bazel_tools//platforms have been removed. Please use constraints from @platforms repository embedded in Bazel, or preferably declare dependency on https://github.com/bazelbuild/platforms. See https://github.com/bazelbuild/bazel/issues/8622 for details.
Step #3 - "compile-afl-address-x86_64": Analyzing: 8 targets (34 packages loaded, 44 targets configured)
Step #3 - "compile-afl-address-x86_64":     currently loading: @rules_fuzzing//fuzzing/tools
Step #3 - "compile-afl-address-x86_64":     Fetching repository @fuzzing_py_deps; Restarting.
Step #3 - "compile-afl-address-x86_64":     Fetching repository @pypi__build; starting
Step #3 - "compile-afl-address-x86_64": 



ERROR: /root/.cache/bazel/_bazel_root/c8255052695dac5944bb165668b0ceed/external/bazel_tools/platforms/BUILD:89:6: Analysis of target '@bazel_tools//platforms:windows' failed
Step #3 - "compile-afl-address-x86_64": Analyzing: 8 targets (34 packages loaded, 47 targets configured)
Step #3 - "compile-afl-address-x86_64":     currently loading: @rules_fuzzing//fuzzing/tools
Step #3 - "compile-afl-address-x86_64":     Fetching repository @fuzzing_py_deps; Restarting.
Step #3 - "compile-afl-address-x86_64":     Fetching repository @pypi__build; starting
Step #3 - "compile-afl-address-x86_64": 



INFO: Repository pypi__build instantiated at:
Step #3 - "compile-afl-address-x86_64":   /src/tcmalloc/WORKSPACE:102:19: in <toplevel>
Step #3 - "compile-afl-address-x86_64":   /root/.cache/bazel/_bazel_root/c8255052695dac5944bb165668b0ceed/external/rules_fuzzing/fuzzing/init.bzl:23:16: in rules_fuzzing_init
Step #3 - "compile-afl-address-x86_64":   /root/.cache/bazel/_bazel_root/c8255052695dac5944bb165668b0ceed/external/rules_python/python/pip.bzl:96:29: in pip_install
Step #3 - "compile-afl-address-x86_64":   /root/.cache/bazel/_bazel_root/c8255052695dac5944bb165668b0ceed/external/rules_python/python/pip_install/repositories.bzl:122:14: in pip_install_dependencies
Step #3 - "compile-afl-address-x86_64":   /root/.cache/bazel/_bazel_root/c8255052695dac5944bb165668b0ceed/external/bazel_tools/tools/build_defs/repo/utils.bzl:233:18: in maybe
Step #3 - "compile-afl-address-x86_64": Repository rule http_archive defined at:
Step #3 - "compile-afl-address-x86_64":   /root/.cache/bazel/_bazel_root/c8255052695dac5944bb165668b0ceed/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
Step #3 - "compile-afl-address-x86_64": Analyzing: 8 targets (34 packages loaded, 60 targets configured)
Step #3 - "compile-afl-address-x86_64":     currently loading: @rules_fuzzing//fuzzing/tools
Step #3 - "compile-afl-address-x86_64":     Fetching repository @fuzzing_py_deps; Restarting.
Step #3 - "compile-afl-address-x86_64":     Fetching repository @pypi__build; starting
Step #3 - "compile-afl-address-x86_64":     Fetching https://files.pythonhosted.org/.../build-0.8.0-py3-none-any.whl

Steps to Reproduce the Problem

  1. git clone https://github.com/google/oss-fuzz
  2. cd oss-fuzz
  3. Undo the changes from https://github.com/google/oss-fuzz/pull/9304
  4. python3 infra/helper.py build_fuzzers tcmalloc

Specifications

fmeum commented 1 year ago

tcmalloc depends on an old version of com_google_protobuf, which in turn depends on a very old version of bazel_skylib (1.0.2) that isn't compatible with Bazel 6.0.0 (the hint is the line /src/tcmalloc/tcmalloc/internal/BUILD:478:13: While resolving toolchains for target //tcmalloc/internal:numa_fuzz_raw_: invalid registered toolchain '@bazel_skylib//toolchains/unittest:cmd_toolchain'). This can be worked around by adding these lines somewhere close to the top of WORKSPACE:

http_archive(
    name = "bazel_skylib",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
    ],
    sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
)

A more sustainable fix would be to have tcmalloc update the dependencies it specifies in WORKSPACE, in particular that on protobuf, but the rules_fuzzing dependency is also quite outdated.

DavidKorczynski commented 1 year ago

Thanks a ton @fmeum -- when I looked further at the other projects using rules_fuzzing indeed it came out they were not failing. Closing this as the issue is not in rules_fuzzing.