HomePhabricator

test: Fix fuzzer compilation on macOS

Description

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

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9134

Details

Provenance
freenancial <freenancial@protonmail.com>Authored on Jul 21 2020, 22:21
FabienCommitted on Feb 3 2021, 10:35
FabienPushed on Feb 3 2021, 10:37
Reviewer
Restricted Project
Differential Revision
D9134: test: Fix fuzzer compilation on macOS
Parents
rABCb8a5566f5524: fuzz: add missing overrides to signature_checker
Branches
Unknown
Tags
Unknown