Fuzzing Bitcoin Core with clang-16 #31922

issue yancyribbens openend this issue on February 21, 2025
  1. yancyribbens commented at 3:15 am on February 21, 2025: contributor

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    building fails during linking CXX executable bitcoin-wallet

     0[ 27%] Building CXX object src/util/CMakeFiles/bitcoin_util.dir/__/sync.cpp.o                                                                                            
     1[ 27%] Linking CXX static library libbitcoin_util.a                                                                                                                      
     2[ 27%] Built target bitcoin_util                                                                                                                                         
     3[ 27%] Building C object src/secp256k1/src/CMakeFiles/secp256k1_precomputed.dir/precomputed_ecmult.c.o                                                                   
     4[ 27%] Building C object src/secp256k1/src/CMakeFiles/secp256k1_precomputed.dir/precomputed_ecmult_gen.c.o                                                               
     5[ 27%] Built target secp256k1_precomputed                                                                                                                                
     6[ 28%] Building C object src/secp256k1/src/CMakeFiles/secp256k1.dir/secp256k1.c.o                                                                                        
     7[ 28%] Linking C static library ../lib/libsecp256k1.a                                                                                                                    
     8[ 28%] Built target secp256k1                                                                                                                                            
     9[ 28%] Building CXX object src/CMakeFiles/bitcoin-wallet.dir/bitcoin-wallet.cpp.o                                                                                        
    10[ 28%] Building CXX object src/CMakeFiles/bitcoin-wallet.dir/init/bitcoin-wallet.cpp.o                                                                                   
    11[ 28%] Building CXX object src/CMakeFiles/bitcoin-wallet.dir/wallet/wallettool.cpp.o                                                                                     
    12[ 28%] Linking CXX executable bitcoin-wallet                                                                                                                             
    13/usr/bin/ld: libbitcoin_common.a(bloom.cpp.o): undefined reference to symbol 'exp@@GLIBC_2.29'                                                                           
    14/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line                                                                        
    15clang: error: linker command failed with exit code 1 (use -v to see invocation)                                                                                          
    16gmake[2]: *** [src/CMakeFiles/bitcoin-wallet.dir/build.make:138: src/bitcoin-wallet] Error 1                                                                             
    17gmake[1]: *** [CMakeFiles/Makefile2:650: src/CMakeFiles/bitcoin-wallet.dir/all] Error 2                                                                                  
    18gmake: *** [Makefile:146: all] Error 2
    

    Expected behaviour

    successful fuzz build.

    Steps to reproduce

    Using master branch:

    cmake -DCMAKE_C_COMPILER=/usr/bin/clang-16 -DCMAKE_CXX_COMPILER=/usr/bin/clang-16 --preset=libfuzzer

    Note here I am using clang-16 because the project fails to even begin the build process due to an error: uint256.h:133:19: error: call to consteval function 'util::ConstevalHexDigit' is not a constant expression. After finding the issue: #30947 I set the compiler to clang-16 which begins the build process but fails 28% through.

    Relevant log output

    No response

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    master@5b8fd7c3a6b8c9c6a9481d340c3bcc67e74993c3

    Operating system and version

    Debian GNU/Linux 12 (bookworm)

    Machine specifications

    No response

  2. maflcko commented at 8:25 am on February 21, 2025: member

    [ 28%] Linking CXX executable bitcoin-wallet

    There is no such executable in the fuzz build target. When using cmake, you will have to delete the build folder before configuring. Otherwise the build could be stale.

    Also, your system has clang-19 available to use, see https://packages.debian.org/bookworm/clang-19

    What are the exact steps to reproduce?

    I can’t reproduce this locally with:

    0rm -rf ./bld-fzz && cmake -DCMAKE_C_COMPILER=/usr/bin/clang-16 -DCMAKE_CXX_COMPILER=/usr/bin/clang-16 -DSANITIZERS=fuzzer -DBUILD_FOR_FUZZING=ON -B ./bld-fzz && cmake --build ./bld-fzz -j $(nproc)
    

    Unrelated to your issue, it seems there are link issues with ubsan, so you’ll probably want to exclude that for now:

    0rm -rf ./bld-fzz && cmake -DCMAKE_C_COMPILER=/usr/bin/clang-19 -DCMAKE_CXX_COMPILER=/usr/bin/clang-19 --preset=libfuzzer -DSANITIZERS=fuzzer,address  -B ./bld-fzz && cmake --build ./bld-fzz -j $(nproc)
    
  3. yancyribbens commented at 10:38 pm on February 21, 2025: contributor

    What are the exact steps to reproduce?

    Following the docs here: https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md. cmake --preset=libfuzzer was fine, it was the next cmake --build build_fuzz that was failing.

    Looks like nuking ./bld-fzz did the trick. Should have thought to try a fresh checkout. Thanks!

  4. yancyribbens closed this on Feb 21, 2025


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: 2025-02-22 06:12 UTC

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