Page MenuHomePhabricator

test: Fix fuzzer compilation on macOS
ClosedPublic

Authored by Fabien on Feb 2 2021, 17:00.

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABC4020a2155635: test: Fix fuzzer compilation on macOS
Summary
Before the fix:

➜  bitcoin git:(fix-fuzzer-macos) make
Making all in src
  CXX      test/fuzz/addition_overflow-addition_overflow.o
In file included from test/fuzz/addition_overflow.cpp:7:
./test/fuzz/util.h:335:13: error: no matching function for call to
'AdditionOverflow'
        if (AdditionOverflow((uint64_t)fuzzed_file->m_offset,
random_bytes.size())) {
            ^~~~~~~~~~~~~~~~
./test/fuzz/util.h:201:16: note: candidate template ignored: deduced
conflicting types for parameter 'T' ('unsigned long long' vs. 'unsigned
long')
NODISCARD bool AdditionOverflow(const T i, const T j) noexcept
               ^
./test/fuzz/util.h:346:13: error: no matching function for call to
'AdditionOverflow'
        if (AdditionOverflow(fuzzed_file->m_offset, n)) {
            ^~~~~~~~~~~~~~~~
./test/fuzz/util.h:201:16: note: candidate template ignored: deduced
conflicting types for parameter 'T' ('long long' vs. 'long')
NODISCARD bool AdditionOverflow(const T i, const T j) noexcept
               ^

After the fix:

➜  bitcoin git:(fix-fuzzer-macos) ./configure --enable-fuzz
--with-sanitizers=fuzzer,address,undefined
CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++
--disable-asm && make clean && make -j5
...
...
  CXXLD    test/fuzz/uint256_deserialize
Making all in doc/man
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all-am'.

Backport of core PR19562.

Depends on D9132.

Test Plan

On OSX:

ninja bitcoin-fuzzers

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable