test: recently merged fuzzers don’t compile on macOS #19557

issue fanquake openend this issue on July 20, 2020
  1. fanquake commented at 3:48 am on July 20, 2020: member

    The fuzzing harnesses from #19143 don’t compile on macOS. i.e building at 476436b2dec254bb988f8c7a6cbec1d7bb7cecfd:

     0In file included from test/fuzz/addition_overflow.cpp:7:
     1./test/fuzz/util.h:335:13: error: no matching function for call to 'AdditionOverflow'
     2        if (AdditionOverflow((uint64_t)fuzzed_file->m_offset, random_bytes.size())) {
     3            ^~~~~~~~~~~~~~~~
     4./test/fuzz/util.h:201:16: note: candidate template ignored: deduced conflicting types for parameter 'T' ('unsigned long long' vs. 'unsigned long')
     5NODISCARD bool AdditionOverflow(const T i, const T j) noexcept
     6               ^
     7./test/fuzz/util.h:346:13: error: no matching function for call to 'AdditionOverflow'
     8        if (AdditionOverflow(fuzzed_file->m_offset, n)) {
     9            ^~~~~~~~~~~~~~~~
    10./test/fuzz/util.h:201:16: note: candidate template ignored: deduced conflicting types for parameter 'T' ('long long' vs. 'long')
    11NODISCARD bool AdditionOverflow(const T i, const T j) noexcept
    12               ^
    132 errors generated.
    14
    15In file included from test/fuzz/buffered_file.cpp:9:
    16./test/fuzz/util.h:335:13: error: no matching function for call to 'AdditionOverflow'
    17        if (AdditionOverflow((uint64_t)fuzzed_file->m_offset, random_bytes.size())) {
    18            ^~~~~~~~~~~~~~~~
    19./test/fuzz/util.h:201:16: note: candidate template ignored: deduced conflicting types for parameter 'T' ('unsigned long long' vs. 'unsigned long')
    20NODISCARD bool AdditionOverflow(const T i, const T j) noexcept
    21               ^
    22./test/fuzz/util.h:346:13: error: no matching function for call to 'AdditionOverflow'
    23        if (AdditionOverflow(fuzzed_file->m_offset, n)) {
    24            ^~~~~~~~~~~~~~~~
    25./test/fuzz/util.h:201:16: note: candidate template ignored: deduced conflicting types for parameter 'T' ('long long' vs. 'long')
    26NODISCARD bool AdditionOverflow(const T i, const T j) noexcept
    27               ^
    282 errors generated.
    
  2. fanquake added the label Bug on Jul 20, 2020
  3. fanquake added the label Tests on Jul 20, 2020
  4. fanquake assigned practicalswift on Jul 20, 2020
  5. fanquake removed the label Bug on Jul 20, 2020
  6. fanquake added the label macOS on Jul 20, 2020
  7. practicalswift commented at 2:21 pm on July 21, 2020: contributor

    @fanquake Thanks for reporting and thanks for the ping! Unfortunately I don’t have any Mac around to test with but the following patch should make it compile? :) Feel free to submit as PR if it looks good.

     0diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h
     1index 148610c04..e47ad47f2 100644
     2--- a/src/test/fuzz/util.h
     3+++ b/src/test/fuzz/util.h
     4@@ -332,7 +332,7 @@ public:
     5             return 0;
     6         }
     7         std::memcpy(buf, random_bytes.data(), random_bytes.size());
     8-        if (AdditionOverflow((uint64_t)fuzzed_file->m_offset, random_bytes.size())) {
     9+        if (AdditionOverflow(fuzzed_file->m_offset, (int64_t)random_bytes.size())) {
    10             return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1;
    11         }
    12         fuzzed_file->m_offset += random_bytes.size();
    13@@ -343,7 +343,7 @@ public:
    14     {
    15         FuzzedFileProvider* fuzzed_file = (FuzzedFileProvider*)cookie;
    16         const ssize_t n = fuzzed_file->m_fuzzed_data_provider.ConsumeIntegralInRange<ssize_t>(0, size);
    17-        if (AdditionOverflow(fuzzed_file->m_offset, n)) {
    18+        if (AdditionOverflow(fuzzed_file->m_offset, (int64_t)n)) {
    19             return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1;
    20         }
    21         fuzzed_file->m_offset += n;
    
  8. fanquake unassigned practicalswift on Jul 21, 2020
  9. fanquake added the label good first issue on Jul 21, 2020
  10. fanquake commented at 3:01 pm on July 21, 2020: member
    @practicalswift Thanks. I’ll throw a good first issue tag on here, and if someone wants to test and pick this up as their first change they can. Otherwise I’ll test and PR it shortly.
  11. freenancial commented at 4:56 pm on July 21, 2020: contributor

    Hi, @fanquake , I would like to give it a shot and see if I could get it fixed.

    How do I reproduce this issue please? Is it simply a make check on macOS? Thanks!

  12. jonatack commented at 5:01 pm on July 21, 2020: member
    @freenancial you can test by doing a fuzz build for macOS at commit 476436b2dec254bb988f8c7a6cbec1d7bb7cecfd versus with your proposed fix. See https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md for more information on building for fuzzing. Personally, I build for fuzzing with ./autogen.sh ; ./configure --enable-c++17 --enable-fuzz --with-sanitizers=address,fuzzer,undefined CC=clang CXX=clang++ && make clean ; make -j5. If you find the build docs here confusing, you can also try following this build tutorial I wrote: https://jonatack.github.io/articles/how-to-compile-bitcoin-core-and-run-the-tests
  13. freenancial referenced this in commit 895d965d55 on Jul 21, 2020
  14. freenancial referenced this in commit c8992e8959 on Jul 21, 2020
  15. fanquake closed this on Jul 22, 2020

  16. fanquake referenced this in commit 2031aa92a3 on Jul 22, 2020
  17. sidhujag referenced this in commit 1c3f2fab7d on Jul 24, 2020
  18. JeremyRubin referenced this in commit 2926720807 on Jul 27, 2020
  19. Warchant referenced this in commit f9b2e611b5 on Aug 6, 2020
  20. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-09-29 01:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me