bitcoin: build: x86 afl++ ASan build broken "error: inline assembly requires more registers than available"

Dockerfile to reproduce: https://gist.github.com/dergoegge/fc97743028f60719759b5498f5f022bf

Building with clang-19 and -fsantize=address fails with:

7.574 /bitcoin/src/secp256k1/src/scalar_4x64_impl.h:356:5: error: inline assembly requires more registers than available
7.574   356 |     "movq 32(%%rsi), %%r11\n"
7.574       |     ^
7.575 /bitcoin/src/secp256k1/src/scalar_4x64_impl.h:356:5: error: inline assembly requires more registers than available
7.575 /bitcoin/src/secp256k1/src/scalar_4x64_impl.h:356:5: error: inline assembly requires more registers than available
7.643 [ 24%] Building CXX object src/CMakeFiles/bitcoin_consensus.dir/uint256.cpp.o
7.722 3 errors generated.
7.738 gmake[3]: *** [src/secp256k1/src/CMakeFiles/secp256k1.dir/build.make:76: src/secp256k1/src/CMakeFiles/secp256k1.dir/secp256k1.c.o] Error 1
7.738 gmake[2]: *** [CMakeFiles/Makefile2:1020: src/secp256k1/src/CMakeFiles/secp256k1.dir/all] Error 2

Since this looks secp256k1 related I tried reproducing on a separate secp build but couldn’t. This could very well be a compiler/linker bug.

I am surprised that I’m the only one running into this, we don’t have a x86 ASan job anywhere? I think I first observed this sometime mid last year.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 25 (25 by maintainers)

Commits related to this issue

Most upvoted comments

Could someone provide configuration options and a line from the verbose build to show what exactly is broken?

Reproduced as follows:

# clone and checkout hash before addr san was disabled
git clone git@github.com:dergoegge/fuzzamoto.git && cd fuzzamoto && git checkout 3f72735 
docker build .
# or, to get full logs
docker build --no-cache --progress=plain . 2>&1 | tee build.log

Here is the configure line, and noteworthy output:

$ cmake -B build_fuzz       --toolchain ./depends/$(./depends/config.guess)/toolchain.cmake       -DSANITIZERS="address"       -DAPPEND_CPPFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"       -DAPPEND_CFLAGS="-fcf-protection=none"       -DAPPEND_CXXFLAGS="-fcf-protection=none"       -DAPPEND_LDFLAGS="-fcf-protection=none"
C++ compiler flags .................... -pipe -std=c++20 -O2 -g -std=c++20 -fPIC -fdebug-prefix-map=/bitcoin/src=. -fmacro-prefix-map=/bitcoin/src=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -fsanitize=address -Wall -Wextra -Wgnu -Wformat -Wformat-security -Wvla -Wshadow-field -Wthread-safety -Wloop-analysis -Wredundant-decls -Wunused-member-function -Wdate-time -Wconditional-uninitialized -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wdocumentation -Wself-assign -Wundef -Wno-unused-parameter -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fcf-protection=none
Linker flags .......................... -pipe -std=c++20 -O2 -g -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fsanitize=address -fPIE -pie -fcf-protection=none
Full configure output
#26 [22/44] RUN cd bitcoin/ && cmake -B build_fuzz       --toolchain ./depends/$(./depends/config.guess)/toolchain.cmake       -DSANITIZERS="address"       -DAPPEND_CPPFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"       -DAPPEND_CFLAGS="-fcf-protection=none"       -DAPPEND_CXXFLAGS="-fcf-protection=none"       -DAPPEND_LDFLAGS="-fcf-protection=none"
#26 0.231 -- The CXX compiler identification is Clang 19.1.7
#26 0.234 -- Detecting CXX compiler ABI info
#26 0.298 -- Detecting CXX compiler ABI info - done
#26 0.303 -- Check for working CXX compiler: /AFLplusplus/afl-clang-fast++ - skipped
#26 0.303 -- Detecting CXX compile features
#26 0.303 -- Detecting CXX compile features - done
#26 0.304 -- Setting build type to "RelWithDebInfo" as none was specified
#26 0.304 -- Performing Test CXX_SUPPORTS__WERROR
#26 0.347 -- Performing Test CXX_SUPPORTS__WERROR - Success
#26 0.347 -- Performing Test CXX_SUPPORTS__G3
#26 0.391 -- Performing Test CXX_SUPPORTS__G3 - Success
#26 0.391 -- Performing Test LINKER_SUPPORTS__G3
#26 0.452 -- Performing Test LINKER_SUPPORTS__G3 - Success
#26 0.452 -- Performing Test CXX_SUPPORTS__FTRAPV
#26 0.498 -- Performing Test CXX_SUPPORTS__FTRAPV - Success
#26 0.498 -- Performing Test LINKER_SUPPORTS__FTRAPV
#26 0.558 -- Performing Test LINKER_SUPPORTS__FTRAPV - Success
#26 0.559 -- Found SQLite3: /bitcoin/depends/x86_64-pc-linux-gnu/include (found suitable version "3.46.1", minimum required is "3.7.17") 
#26 0.701 -- Performing Test LINKER_SUPPORTS__WL___FATAL_WARNINGS
#26 0.776 -- Performing Test LINKER_SUPPORTS__WL___FATAL_WARNINGS - Success
#26 0.777 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
#26 0.853 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
#26 0.853 -- Found Threads: TRUE  
#26 0.854 -- Performing Test CXX_SUPPORTS__FSANITIZE_ADDRESS
#26 0.898 -- Performing Test CXX_SUPPORTS__FSANITIZE_ADDRESS - Success
#26 0.898 -- Performing Test LINKER_SUPPORTS__FSANITIZE_ADDRESS_6231
#26 1.001 -- Performing Test LINKER_SUPPORTS__FSANITIZE_ADDRESS_6231 - Success
#26 1.007 -- Found Boost: /bitcoin/depends/x86_64-pc-linux-gnu/include (found suitable version "1.81.0", minimum required is "1.73.0")  
#26 1.007 -- Performing Test NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE
#26 1.036 -- Performing Test NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE - Failed
#26 1.037 -- Found Libevent: /bitcoin/depends/x86_64-pc-linux-gnu/lib/cmake/libevent (found suitable version "2.1.12", minimum required is "2.1.8") 
#26 1.037 -- Performing Test HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
#26 1.065 -- Performing Test HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR - Failed
#26 1.065 -- Looking for C++ include sys/prctl.h
#26 1.136 -- Looking for C++ include sys/prctl.h - found
#26 1.136 -- Looking for C++ include sys/resources.h
#26 1.157 -- Looking for C++ include sys/resources.h - not found
#26 1.157 -- Looking for C++ include sys/vmmeter.h
#26 1.178 -- Looking for C++ include sys/vmmeter.h - not found
#26 1.178 -- Looking for C++ include vm/vm_param.h
#26 1.198 -- Looking for C++ include vm/vm_param.h - not found
#26 1.198 -- Looking for O_CLOEXEC
#26 1.270 -- Looking for O_CLOEXEC - found
#26 1.270 -- Looking for fdatasync
#26 1.345 -- Looking for fdatasync - found
#26 1.345 -- Looking for fork
#26 1.418 -- Looking for fork - found
#26 1.418 -- Looking for pipe2
#26 1.491 -- Looking for pipe2 - found
#26 1.491 -- Looking for setsid
#26 1.566 -- Looking for setsid - found
#26 1.566 -- Looking for C++ include sys/types.h
#26 1.640 -- Looking for C++ include sys/types.h - found
#26 1.640 -- Looking for C++ include ifaddrs.h
#26 1.715 -- Looking for C++ include ifaddrs.h - found
#26 1.715 -- Performing Test IFADDR_LINKS_WITHOUT_LIBSOCKET
#26 1.792 -- Performing Test IFADDR_LINKS_WITHOUT_LIBSOCKET - Success
#26 1.792 -- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC
#26 2.058 -- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC - Success
#26 2.058 -- Looking for std::system
#26 2.139 -- Looking for std::system - found
#26 2.139 -- Looking for ::_wsystem
#26 2.164 -- Looking for ::_wsystem - not found
#26 2.164 -- Performing Test STRERROR_R_CHAR_P
#26 2.238 -- Performing Test STRERROR_R_CHAR_P - Success
#26 2.238 -- Looking for malloc_info
#26 2.313 -- Looking for malloc_info - found
#26 2.313 -- Performing Test HAVE_MALLOPT_ARENA_MAX
#26 2.386 -- Performing Test HAVE_MALLOPT_ARENA_MAX - Success
#26 2.386 -- Performing Test HAVE_POSIX_FALLOCATE
#26 2.460 -- Performing Test HAVE_POSIX_FALLOCATE - Success
#26 2.460 -- Performing Test HAVE_STRONG_GETAUXVAL
#26 2.532 -- Performing Test HAVE_STRONG_GETAUXVAL - Success
#26 2.532 -- Performing Test HAVE_SOCKADDR_UN
#26 2.607 -- Performing Test HAVE_SOCKADDR_UN - Success
#26 2.607 -- Performing Test HAVE_GETRANDOM
#26 2.680 -- Performing Test HAVE_GETRANDOM - Success
#26 2.680 -- Performing Test HAVE_GETENTROPY_RAND
#26 2.757 -- Performing Test HAVE_GETENTROPY_RAND - Success
#26 2.757 -- Performing Test HAVE_SYSCTL
#26 2.780 -- Performing Test HAVE_SYSCTL - Failed
#26 2.780 -- Performing Test HAVE_SYSCTL_ARND
#26 2.802 -- Performing Test HAVE_SYSCTL_ARND - Failed
#26 2.802 -- Performing Test HAVE_SSE41
#26 2.965 -- Performing Test HAVE_SSE41 - Success
#26 2.965 -- Performing Test HAVE_AVX2
#26 3.127 -- Performing Test HAVE_AVX2 - Success
#26 3.127 -- Performing Test HAVE_X86_SHANI
#26 3.284 -- Performing Test HAVE_X86_SHANI - Success
#26 3.284 -- Performing Test HAVE_ARM_SHANI
#26 3.304 -- Performing Test HAVE_ARM_SHANI - Failed
#26 3.304 -- Performing Test CXX_SUPPORTS__WALL
#26 3.346 -- Performing Test CXX_SUPPORTS__WALL - Success
#26 3.346 -- Performing Test CXX_SUPPORTS__WEXTRA
#26 3.388 -- Performing Test CXX_SUPPORTS__WEXTRA - Success
#26 3.388 -- Performing Test CXX_SUPPORTS__WGNU
#26 3.431 -- Performing Test CXX_SUPPORTS__WGNU - Success
#26 3.431 -- Performing Test CXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY
#26 3.474 -- Performing Test CXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY - Success
#26 3.474 -- Performing Test CXX_SUPPORTS__WVLA
#26 3.517 -- Performing Test CXX_SUPPORTS__WVLA - Success
#26 3.517 -- Performing Test CXX_SUPPORTS__WSHADOW_FIELD
#26 3.557 -- Performing Test CXX_SUPPORTS__WSHADOW_FIELD - Success
#26 3.558 -- Performing Test CXX_SUPPORTS__WTHREAD_SAFETY
#26 3.599 -- Performing Test CXX_SUPPORTS__WTHREAD_SAFETY - Success
#26 3.599 -- Performing Test CXX_SUPPORTS__WLOOP_ANALYSIS
#26 3.644 -- Performing Test CXX_SUPPORTS__WLOOP_ANALYSIS - Success
#26 3.644 -- Performing Test CXX_SUPPORTS__WREDUNDANT_DECLS
#26 3.686 -- Performing Test CXX_SUPPORTS__WREDUNDANT_DECLS - Success
#26 3.687 -- Performing Test CXX_SUPPORTS__WUNUSED_MEMBER_FUNCTION
#26 3.727 -- Performing Test CXX_SUPPORTS__WUNUSED_MEMBER_FUNCTION - Success
#26 3.727 -- Performing Test CXX_SUPPORTS__WDATE_TIME
#26 3.769 -- Performing Test CXX_SUPPORTS__WDATE_TIME - Success
#26 3.769 -- Performing Test CXX_SUPPORTS__WCONDITIONAL_UNINITIALIZED
#26 3.811 -- Performing Test CXX_SUPPORTS__WCONDITIONAL_UNINITIALIZED - Success
#26 3.811 -- Performing Test CXX_SUPPORTS__WDUPLICATED_BRANCHES
#26 3.830 -- Performing Test CXX_SUPPORTS__WDUPLICATED_BRANCHES - Failed
#26 3.830 -- Performing Test CXX_SUPPORTS__WDUPLICATED_COND
#26 3.848 -- Performing Test CXX_SUPPORTS__WDUPLICATED_COND - Failed
#26 3.848 -- Performing Test CXX_SUPPORTS__WLOGICAL_OP
#26 3.867 -- Performing Test CXX_SUPPORTS__WLOGICAL_OP - Failed
#26 3.867 -- Performing Test CXX_SUPPORTS__WOVERLOADED_VIRTUAL
#26 3.908 -- Performing Test CXX_SUPPORTS__WOVERLOADED_VIRTUAL - Success
#26 3.909 -- Performing Test CXX_SUPPORTS__WSUGGEST_OVERRIDE
#26 3.949 -- Performing Test CXX_SUPPORTS__WSUGGEST_OVERRIDE - Success
#26 3.949 -- Performing Test CXX_SUPPORTS__WIMPLICIT_FALLTHROUGH
#26 3.989 -- Performing Test CXX_SUPPORTS__WIMPLICIT_FALLTHROUGH - Success
#26 3.990 -- Performing Test CXX_SUPPORTS__WUNREACHABLE_CODE
#26 4.030 -- Performing Test CXX_SUPPORTS__WUNREACHABLE_CODE - Success
#26 4.030 -- Performing Test CXX_SUPPORTS__WDOCUMENTATION
#26 4.072 -- Performing Test CXX_SUPPORTS__WDOCUMENTATION - Success
#26 4.072 -- Performing Test CXX_SUPPORTS__WSELF_ASSIGN
#26 4.114 -- Performing Test CXX_SUPPORTS__WSELF_ASSIGN - Success
#26 4.114 -- Performing Test CXX_SUPPORTS__WBIDI_CHARS_ANY
#26 4.133 -- Performing Test CXX_SUPPORTS__WBIDI_CHARS_ANY - Failed
#26 4.133 -- Performing Test CXX_SUPPORTS__WUNDEF
#26 4.175 -- Performing Test CXX_SUPPORTS__WUNDEF - Success
#26 4.175 -- Performing Test CXX_SUPPORTS__WUNUSED_PARAMETER
#26 4.217 -- Performing Test CXX_SUPPORTS__WUNUSED_PARAMETER - Success
#26 4.217 -- Performing Test CXX_SUPPORTS__FNO_EXTENDED_IDENTIFIERS
#26 4.236 -- Performing Test CXX_SUPPORTS__FNO_EXTENDED_IDENTIFIERS - Failed
#26 4.236 -- Performing Test CXX_SUPPORTS__FDEBUG_PREFIX_MAP_A_B
#26 4.278 -- Performing Test CXX_SUPPORTS__FDEBUG_PREFIX_MAP_A_B - Success
#26 4.278 -- Performing Test CXX_SUPPORTS__FMACRO_PREFIX_MAP_A_B
#26 4.321 -- Performing Test CXX_SUPPORTS__FMACRO_PREFIX_MAP_A_B - Success
#26 4.321 -- Performing Test CXX_SUPPORTS__FSTACK_REUSE_NONE
#26 4.340 -- Performing Test CXX_SUPPORTS__FSTACK_REUSE_NONE - Failed
#26 4.340 -- Performing Test CXX_SUPPORTS__U_FORTIFY_SOURCE__D_FORTIFY_SOURCE_3_2d08
#26 4.381 -- Performing Test CXX_SUPPORTS__U_FORTIFY_SOURCE__D_FORTIFY_SOURCE_3_2d08 - Success
#26 4.381 -- Performing Test LINKER_SUPPORTS__U_FORTIFY_SOURCE__D_FORTIFY_SOURCE_3_2d08
#26 4.449 -- Performing Test LINKER_SUPPORTS__U_FORTIFY_SOURCE__D_FORTIFY_SOURCE_3_2d08 - Success
#26 4.449 -- Performing Test CXX_SUPPORTS__WSTACK_PROTECTOR
#26 4.491 -- Performing Test CXX_SUPPORTS__WSTACK_PROTECTOR - Success
#26 4.491 -- Performing Test CXX_SUPPORTS__FSTACK_PROTECTOR_ALL
#26 4.534 -- Performing Test CXX_SUPPORTS__FSTACK_PROTECTOR_ALL - Success
#26 4.534 -- Performing Test LINKER_SUPPORTS__FSTACK_PROTECTOR_ALL
#26 4.603 -- Performing Test LINKER_SUPPORTS__FSTACK_PROTECTOR_ALL - Success
#26 4.603 -- Performing Test CXX_SUPPORTS__FCF_PROTECTION_FULL
#26 4.646 -- Performing Test CXX_SUPPORTS__FCF_PROTECTION_FULL - Success
#26 4.647 -- Performing Test LINKER_SUPPORTS__FCF_PROTECTION_FULL
#26 4.714 -- Performing Test LINKER_SUPPORTS__FCF_PROTECTION_FULL - Success
#26 4.714 -- Performing Test CXX_SUPPORTS__FSTACK_CLASH_PROTECTION
#26 4.757 -- Performing Test CXX_SUPPORTS__FSTACK_CLASH_PROTECTION - Success
#26 4.757 -- Performing Test LINKER_SUPPORTS__FSTACK_CLASH_PROTECTION
#26 4.825 -- Performing Test LINKER_SUPPORTS__FSTACK_CLASH_PROTECTION - Success
#26 4.825 -- Performing Test LINKER_SUPPORTS__WL___ENABLE_RELOC_SECTION
#26 4.868 -- Performing Test LINKER_SUPPORTS__WL___ENABLE_RELOC_SECTION - Failed
#26 4.868 -- Performing Test LINKER_SUPPORTS__WL___DYNAMICBASE
#26 4.910 -- Performing Test LINKER_SUPPORTS__WL___DYNAMICBASE - Failed
#26 4.910 -- Performing Test LINKER_SUPPORTS__WL___NXCOMPAT
#26 4.953 -- Performing Test LINKER_SUPPORTS__WL___NXCOMPAT - Failed
#26 4.953 -- Performing Test LINKER_SUPPORTS__WL___HIGH_ENTROPY_VA
#26 4.996 -- Performing Test LINKER_SUPPORTS__WL___HIGH_ENTROPY_VA - Failed
#26 4.997 -- Performing Test LINKER_SUPPORTS__WL__Z_RELRO
#26 5.065 -- Performing Test LINKER_SUPPORTS__WL__Z_RELRO - Success
#26 5.065 -- Performing Test LINKER_SUPPORTS__WL__Z_NOW
#26 5.134 -- Performing Test LINKER_SUPPORTS__WL__Z_NOW - Success
#26 5.134 -- Performing Test LINKER_SUPPORTS__WL__Z_SEPARATE_CODE
#26 5.205 -- Performing Test LINKER_SUPPORTS__WL__Z_SEPARATE_CODE - Success
#26 5.247 -- Found Python3: /usr/bin/python3 (found suitable version "3.11.2", minimum required is "3.10") found components: Interpreter 
#26 5.253 -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE dot) 
#26 5.255 -- Performing Test HAVE_BUILTIN_PREFETCH
#26 5.329 -- Performing Test HAVE_BUILTIN_PREFETCH - Success
#26 5.329 -- Performing Test HAVE_MM_PREFETCH
#26 5.413 -- Performing Test HAVE_MM_PREFETCH - Success
#26 5.413 -- Performing Test HAVE_SSE42
#26 5.498 -- Performing Test HAVE_SSE42 - Success
#26 5.498 -- Performing Test HAVE_ARM64_CRC32C
#26 5.518 -- Performing Test HAVE_ARM64_CRC32C - Failed
#26 5.518 -- Looking for F_FULLFSYNC
#26 5.538 -- Looking for F_FULLFSYNC - not found
#26 5.539 -- Performing Test HAVE_CLMUL
#26 5.697 -- Performing Test HAVE_CLMUL - Success
#26 5.698 
#26 5.698 Configuring secp256k1 subtree...
#26 5.732 -- The C compiler identification is Clang 19.1.7
#26 5.735 -- Detecting C compiler ABI info
#26 5.783 -- Detecting C compiler ABI info - done
#26 5.788 -- Check for working C compiler: /AFLplusplus/afl-clang-fast - skipped
#26 5.788 -- Detecting C compile features
#26 5.788 -- Detecting C compile features - done
#26 5.789 -- Performing Test HAVE_X86_64_ASM
#26 5.835 -- Performing Test HAVE_X86_64_ASM - Success
#26 5.836 -- Could NOT find Valgrind (missing: Valgrind_INCLUDE_DIR Valgrind_WORKS) 
#26 5.836 -- Performing Test C_SUPPORTS__PEDANTIC
#26 5.881 -- Performing Test C_SUPPORTS__PEDANTIC - Success
#26 5.882 -- Performing Test C_SUPPORTS__WALL
#26 5.924 -- Performing Test C_SUPPORTS__WALL - Success
#26 5.924 -- Performing Test C_SUPPORTS__WCAST_ALIGN
#26 5.968 -- Performing Test C_SUPPORTS__WCAST_ALIGN - Success
#26 5.968 -- Performing Test C_SUPPORTS__WCAST_ALIGN_STRICT
#26 5.987 -- Performing Test C_SUPPORTS__WCAST_ALIGN_STRICT - Failed
#26 5.987 -- Performing Test C_SUPPORTS__WCONDITIONAL_UNINITIALIZED
#26 6.030 -- Performing Test C_SUPPORTS__WCONDITIONAL_UNINITIALIZED - Success
#26 6.031 -- Performing Test C_SUPPORTS__WEXTRA
#26 6.074 -- Performing Test C_SUPPORTS__WEXTRA - Success
#26 6.074 -- Performing Test C_SUPPORTS__WNESTED_EXTERNS
#26 6.116 -- Performing Test C_SUPPORTS__WNESTED_EXTERNS - Success
#26 6.117 -- Performing Test C_SUPPORTS__WNO_LONG_LONG
#26 6.161 -- Performing Test C_SUPPORTS__WNO_LONG_LONG - Success
#26 6.162 -- Performing Test C_SUPPORTS__WNO_OVERLENGTH_STRINGS
#26 6.204 -- Performing Test C_SUPPORTS__WNO_OVERLENGTH_STRINGS - Success
#26 6.204 -- Performing Test C_SUPPORTS__WNO_UNUSED_FUNCTION
#26 6.246 -- Performing Test C_SUPPORTS__WNO_UNUSED_FUNCTION - Success
#26 6.247 -- Performing Test C_SUPPORTS__WRESERVED_IDENTIFIER
#26 6.290 -- Performing Test C_SUPPORTS__WRESERVED_IDENTIFIER - Success
#26 6.291 -- Performing Test C_SUPPORTS__WSHADOW
#26 6.333 -- Performing Test C_SUPPORTS__WSHADOW - Success
#26 6.334 -- Performing Test C_SUPPORTS__WSTRICT_PROTOTYPES
#26 6.377 -- Performing Test C_SUPPORTS__WSTRICT_PROTOTYPES - Success
#26 6.378 -- Performing Test C_SUPPORTS__WUNDEF
#26 6.420 -- Performing Test C_SUPPORTS__WUNDEF - Success
#26 6.422 
#26 6.422 
#26 6.422 secp256k1 configure summary
#26 6.422 ===========================
#26 6.422 Build artifacts:
#26 6.422   library type ........................ Static
#26 6.422 Optional modules:
#26 6.422   ECDH ................................ OFF
#26 6.422   ECDSA pubkey recovery ............... ON
#26 6.422   extrakeys ........................... ON
#26 6.422   schnorrsig .......................... ON
#26 6.422   musig ............................... OFF
#26 6.422   ElligatorSwift ...................... ON
#26 6.422 Parameters:
#26 6.422   ecmult window size .................. 15
#26 6.422   ecmult gen table size ............... 86 KiB
#26 6.422 Optional features:
#26 6.422   assembly ............................ x86_64
#26 6.422   external callbacks .................. OFF
#26 6.422 Optional binaries:
#26 6.422   benchmark ........................... OFF
#26 6.422   noverify_tests ...................... ON
#26 6.422   tests ............................... ON
#26 6.422   exhaustive tests .................... ON
#26 6.422   ctime_tests ......................... OFF
#26 6.422   examples ............................ OFF
#26 6.422 
#26 6.422 Cross compiling ....................... FALSE
#26 6.422 Valgrind .............................. OFF
#26 6.422 Preprocessor defined macros ........... ENABLE_MODULE_ELLSWIFT=1 ENABLE_MODULE_SCHNORRSIG=1 ENABLE_MODULE_EXTRAKEYS=1 ENABLE_MODULE_RECOVERY=1 ECMULT_WINDOW_SIZE=15 COMB_BLOCKS=43 COMB_TEETH=6 USE_ASM_X86_64=1
#26 6.422 C compiler ............................ Clang 19.1.7, /AFLplusplus/afl-clang-fast
#26 6.422 CFLAGS ................................ -pipe -std=c11
#26 6.422 Compile options ....................... -pedantic -Wall -Wcast-align -Wconditional-uninitialized -Wextra -Wnested-externs -Wno-long-long -Wno-overlength-strings -Wno-unused-function -Wreserved-identifier -Wshadow -Wstrict-prototypes -Wundef
#26 6.422 Build type:
#26 6.422  - CMAKE_BUILD_TYPE ................... RelWithDebInfo
#26 6.422  - CFLAGS ............................. -O2 -g 
#26 6.422  - LDFLAGS for executables ............ 
#26 6.422  - LDFLAGS for shared libraries ....... 
#26 6.422 SECP256K1_APPEND_CFLAGS ............... -fsanitize=address -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fcf-protection=none
#26 6.422 SECP256K1_APPEND_LDFLAGS .............. -fsanitize=address -fcf-protection=none
#26 6.422 
#26 6.430 
#26 6.430 
#26 6.430 Configure summary
#26 6.430 =================
#26 6.430 Executables:
#26 6.430   bitcoind ............................ ON
#26 6.430   bitcoin-node (multiprocess) ......... OFF
#26 6.430   bitcoin-qt (GUI) .................... OFF
#26 6.430   bitcoin-gui (GUI, multiprocess) ..... OFF
#26 6.430   bitcoin-cli ......................... ON
#26 6.430   bitcoin-tx .......................... ON
#26 6.430   bitcoin-util ........................ ON
#26 6.430   bitcoin-wallet ...................... ON
#26 6.430   bitcoin-chainstate (experimental) ... OFF
#26 6.430   libbitcoinkernel (experimental) ..... OFF
#26 6.430 Optional features:
#26 6.430   wallet support ...................... ON
#26 6.430    - legacy wallets (Berkeley DB) ..... OFF
#26 6.430   external signer ..................... ON
#26 6.430   ZeroMQ .............................. OFF
#26 6.430   IPC ................................. OFF
#26 6.430   USDT tracing ........................ OFF
#26 6.430   QR code (GUI) ....................... OFF
#26 6.430   DBus (GUI, Linux only) .............. OFF
#26 6.430 Tests:
#26 6.430   test_bitcoin ........................ ON
#26 6.430   test_bitcoin-qt ..................... OFF
#26 6.430   bench_bitcoin ....................... OFF
#26 6.430   fuzz binary ......................... OFF
#26 6.430 
#26 6.430 Cross compiling ....................... FALSE
#26 6.430 C++ compiler .......................... Clang 19.1.7, /AFLplusplus/afl-clang-fast++
#26 6.431 CMAKE_BUILD_TYPE ...................... RelWithDebInfo
#26 6.431 Preprocessor defined macros ........... 
#26 6.431 C++ compiler flags .................... -pipe -std=c++20 -O2 -g -std=c++20 -fPIC -fdebug-prefix-map=/bitcoin/src=. -fmacro-prefix-map=/bitcoin/src=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -fsanitize=address -Wall -Wextra -Wgnu -Wformat -Wformat-security -Wvla -Wshadow-field -Wthread-safety -Wloop-analysis -Wredundant-decls -Wunused-member-function -Wdate-time -Wconditional-uninitialized -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wdocumentation -Wself-assign -Wundef -Wno-unused-parameter -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fcf-protection=none
#26 6.431 Linker flags .......................... -pipe -std=c++20 -O2 -g -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fsanitize=address -fPIE -pie -fcf-protection=none
#26 6.431 
#26 6.431 NOTE: The summary above may not exactly match the final applied build flags
#26 6.431       if any additional CMAKE_* or environment variables have been modified.
#26 6.431       To see the exact flags applied, build with the --verbose option.
#26 6.431 
#26 6.431 Treat compiler warnings as errors ..... OFF
#26 6.431 Use ccache for compiling .............. OFF
#26 6.431 
#26 6.431 
#26 6.431 -- Configuring done
#26 6.471 -- Generating done
#26 6.473 -- Build files have been written to: /bitcoin/build_fuzz
#26 DONE 6.5s

And, (modifying the Dockerfile to make the cmake --build --verbose) here is the build command that fails:

#27 25.07 [100%] Linking CXX executable ../bin/bitcoind
#27 25.07 cd /bitcoin/build_fuzz/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/bitcoind.dir/link.txt --verbose=1
#27 25.07 /AFLplusplus/afl-clang-fast++ -pipe -std=c++20 -O2 -g -fstack-protector-all -fcf-protection=full -fstack-clash
-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fsanitize=address -fPIE -pie CMakeFiles/bitcoind.dir/bitcoind.
cpp.o CMakeFiles/bitcoind.dir/init/bitcoind.cpp.o -o ../bin/bitcoind  ../lib/libbitcoin_node.a ../lib/libbitcoin_wallet.
a libleveldb.a libcrc32c.a libminisketch.a /bitcoin/depends/x86_64-pc-linux-gnu/lib/libevent_extra.a /bitcoin/depends/x8
6_64-pc-linux-gnu/lib/libevent_pthreads.a /bitcoin/depends/x86_64-pc-linux-gnu/lib/libevent_core.a ../lib/libbitcoin_com
mon.a ../lib/libbitcoin_util.a ../lib/libbitcoin_clientversion.a ../lib/libbitcoin_consensus.a ../lib/libbitcoin_crypto.
a secp256k1/lib/libsecp256k1.a univalue/libunivalue.a /bitcoin/depends/x86_64-pc-linux-gnu/lib/libsqlite3.a  -fcf-protec
tion=none
#27 218.8 /usr/bin/ld: error: LLVM gold plugin: inline assembly requires more registers than available at line 2171
#27 218.9 clang++: error: linker command failed with exit code 1 (use -v to see invocation)

My guess is that /AFLplusplus/afl-clang-fast++ fails to handle the -fcf-protection=full -fcf-protection=none flags properly.

Could you please try the following patch:

[…]

It failed with this build command:

26.64 /AFLplusplus/afl-clang-fast++ -pipe -std=c++20 -O2 -g -fstack-protector-all -fcf-protection=full -fstack-clash-pro
tection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fsanitize=address -fPIE -pie -fcf-protection=none CMakeFiles/bitco
ind.dir/bitcoind.cpp.o CMakeFiles/bitcoind.dir/init/bitcoind.cpp.o -o ../bin/bitcoind  ../lib/libbitcoin_node.a ../lib/l
ibbitcoin_wallet.a libleveldb.a libcrc32c.a libminisketch.a /bitcoin/depends/x86_64-pc-linux-gnu/lib/libevent_extra.a /b
itcoin/depends/x86_64-pc-linux-gnu/lib/libevent_pthreads.a /bitcoin/depends/x86_64-pc-linux-gnu/lib/libevent_core.a ../l
ib/libbitcoin_common.a ../lib/libbitcoin_util.a ../lib/libbitcoin_clientversion.a ../lib/libbitcoin_consensus.a ../lib/l
ibbitcoin_crypto.a secp256k1/lib/libsecp256k1.a univalue/libunivalue.a /bitcoin/depends/x86_64-pc-linux-gnu/lib/libsqlit
e3.a
231.7 /usr/bin/ld: error: LLVM gold plugin: inline assembly requires more registers than available at line 2171
231.9 clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Now that we’ve removed ENABLE_HARDENING this is happening again. The suggested workaround of injecting flags manually via APPEND_* does not work.

This is an issue for me with https://github.com/dergoegge/fuzzamoto and it’'ll also be a problem on oss-fuzz, when they bump their afl++ version.

So turns out newer versions of afl++ (i.e. newer than the one oss-fuzz is using) will insert -flto when -fcf-protection is detected. That results in -flto -fcf-protection -fsanitize=address and for some reason that combination doesn’t work, not sure if it’s just not supported or there’s a bug but for us a simple workaround is to simply set -DENABLE_HARDENING=OFF when fuzzing with afl++ and ASan on x86. The PR that changed this on the afl++ side is: https://github.com/AFLplusplus/AFLplusplus/pull/1966.

In conclusion, for a plain clang build on x86 with ASan use either -O1 or disable the secp256k1 custom assembly and for a afl-clang-* build with ASan use our -DENABLE_HARDENING=OFF cmake option (this will become relevant for our oss-fuzz build once they bump afl++).

I don’t think there is anything for us left to do here, so closing.

I believe the explanation here is just that they’re incompatible. The asm code in libsecp256k1 requires many registers; an amount which is generally available in builds. But presumably, asan instrumentation reduces the set of general-purpose available register from use in the instrumentation itself, and as a result the code doesn’t compile anymore.