cluster_linearize_tests fails with GCC 16.1 (fixed in GCC 16.2) #35282

issue 1-21gigasats opened this issue on May 13, 2026
  1. 1-21gigasats commented at 3:10 PM on May 13, 2026: none

    Is there an existing issue for this?

    I searched for existing issues and found #32276 / #32325, which looks related because it also involves cluster_linearize, MultiIntBitSet, GCC and array-bounds diagnostics.

    However, this report is about cluster_linearize_tests failing in a normal Bitcoin Core v31.0 test build with GCC 16 on Arch Linux, not the Valgrind fuzz CI warning-as-error case addressed there.

    Current behaviour

    When building Bitcoin Core v31.0 on Arch Linux with the current GCC toolchain, the unit test cluster_linearize_tests fails.

    This was found while preparing an Arch Linux packaging merge request for unrelated packaging fixes:

    https://gitlab.archlinux.org/archlinux/packaging/packages/bitcoin/-/merge_requests/4

    • backporting the upstream Boost >= 1.91 compatibility patch
    • adding missing python to checkdepends

    The Arch package maintainer suggested that an upstream commit would be preferred if this test issue needs to be addressed in the package.

    Expected behaviour

    cluster_linearize_tests should pass with the current GCC toolchain, as it does with GCC 15.2.1 in the same clean Arch Linux chroot setup.

    Steps to reproduce

    On Arch Linux, build Bitcoin Core v31.0 in a clean chroot with the current GCC toolchain and run the test suite.

    In the Arch packaging setup this is done through pkgctl / clean chroot build, with tests enabled through the package check() function:

    ctest --test-dir build

    The relevant test is:

    cluster_linearize_tests

    Relevant log output

    With the older GCC 15.2.1 toolchain, the same package build was tested without the local test patch. In that clean chroot run, cluster_linearize_tests passed and the full test suite completed successfully

    With the current GCC 16 toolchain, cluster_linearize_tests fails. I locally tested the patch below, and with that patch the failing test passed again with the current toolchain.

    I do not know whether this is the correct upstream fix; I am including it only as a data point and possible direction.

      --- a/src/test/cluster_linearize_tests.cpp
      +++ b/src/test/cluster_linearize_tests.cpp
      @@ -56,7 +56,7 @@
    
       void TestOptimalLinearization(std::span<const uint8_t> enc, std::initializer_list<DepGraphIndex> optimal_linearization)
       {
      -    DepGraphIndex tx_count = 0;
      +    DepGraphIndex position_range = 0;
           FastRandomContext rng;
    
           auto test_fn = [&]<typename SetType>() {
      @@ -100,19 +100,22 @@
                   SanityCheck(depgraph, lin);
                   BOOST_CHECK(std::ranges::equal(lin, optimal_linearization));
               }
      -        tx_count = depgraph.PositionRange();
      +        position_range = depgraph.PositionRange();
           };
    
      -    // Always run with 64-bit set types
      -    // - The native one that will be used on this platform.
      -    test_fn.template operator()<BitSet<64>>();
      -    // - The one used on 32-bit platforms.
      -    test_fn.template operator()<bitset_detail::MultiIntBitSet<uint32_t, 2>>();
      -    // - An 8-bit one, which is maximally different in terms of bitset behavior.
      -    test_fn.template operator()<bitset_detail::MultiIntBitSet<uint8_t, 8>>();
      +    // Always run with a set type that can hold all encoded test clusters.
      +    test_fn.template operator()<BitSet<256>>();
      +
      +    // Also run with 64-bit set types if the cluster doesn't use indexes above 63.
      +    if (position_range <= 64) {
      +        // - The native one that will be used on this platform.
      +        test_fn.template operator()<BitSet<64>>();
      +        // - The one used on 32-bit platforms.
      +        test_fn.template operator()<bitset_detail::MultiIntBitSet<uint32_t, 2>>();
      +    }
    
           // Also run with 32-bit set types if the cluster doesn't use indexes above 31.
      -    if (tx_count <= 32) {
      +    if (position_range <= 32) {
               // - The native one that will be used on this platform.
               test_fn.template operator()<BitSet<32>>();
               // - An 8-bit one, which is maximally different in terms of bitset behavior.
    

    How did you obtain Bitcoin Core

    Arch Linux package build: https://gitlab.archlinux.org/archlinux/packaging/packages/bitcoin/-/merge_requests/4

    What version of Bitcoin Core are you using?

    Bitcoin Core v31.0.

    Operating system and version

    Arch Linux.

    The failing setup uses the current Arch GCC 16 toolchain.

    The counter-test used GCC 15.2.1 in the same clean chroot setup, where the unpatched test suite passed:

    gcc 15.2.1+r604+g0b99615a8aef-1 gcc-libs 15.2.1+r604+g0b99615a8aef-1

    Additional context

    I am not a C++ developer and cannot fully judge whether the local patch above is semantically correct. It was generated with help from an LLM and then tested locally.

    The important observations are:

    • cluster_linearize_tests fails with the current GCC 16 toolchain on Arch Linux.
    • The same test passes without the local patch when building with GCC 15.2.1.
    • The local patch above makes the failing test pass with GCC 16.
    • #32276 / #32325 look related, but appear to address a Valgrind fuzz CI array-bounds warning-as-error case rather than this normal unit-test failure.

    Assisted-by: OpenAI Codex (GPT-5.5, reasoning: high)

  2. maflcko commented at 4:08 PM on May 13, 2026: member

    Do you have exact steps to reproduce? My nightly matrix tested archlinux:latest and current master 9 hours ago in https://github.com/maflcko/bitcoin-core-nightly/actions/runs/25781356937/job/75789790765#step:7:463

    This was using GCC 16.1.1:

    Configure summary
    =================
    Executables:
      bitcoin ............................. ON
      bitcoind ............................ ON
      bitcoin-node (multiprocess) ......... ON
      bitcoin-qt (GUI) .................... ON
      bitcoin-gui (GUI, multiprocess) ..... ON
      bitcoin-cli ......................... ON
      bitcoin-tx .......................... ON
      bitcoin-util ........................ ON
      bitcoin-wallet ...................... ON
      bitcoin-chainstate (experimental) ... ON
      libbitcoinkernel (experimental) ..... ON
      kernel-test (experimental) .......... ON
    Optional features:
      wallet support ...................... ON
      external signer ..................... ON
      ZeroMQ .............................. ON
      IPC ................................. ON
      Embedded ASMap ...................... ON
      USDT tracing ........................ ON
      QR code (GUI) ....................... ON
      DBus (GUI) .......................... ON
    Tests:
      test_bitcoin ........................ ON
      test_bitcoin-qt ..................... ON
      bench_bitcoin ....................... ON
      fuzz binary ......................... ON
    
    Cross compiling ....................... FALSE
    C++ compiler .......................... GNU 16.1.1, /usr/sbin/c++
    CMAKE_BUILD_TYPE ...................... RelWithDebInfo
    Preprocessor defined macros ........... 
    C++ compiler flags .................... -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fmacro-prefix-map=/__w/bitcoin-core-nightly/bitcoin-core-nightly/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wleading-whitespace=spaces -Wtrailing-whitespace=any -Wno-unused-parameter -Wno-error=stringop-overflow -Wno-error=sfinae-incomplete
    Linker flags .......................... -O2 -g -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
    
    NOTE: The summary above may not exactly match the final applied build flags
          if any additional CMAKE_* or environment variables have been modified.
          To see the exact flags applied, build with the --verbose option.
    
    Treat compiler warnings as errors ..... ON
    Use ccache for compiling .............. ON
    
    
    -- Configuring done (16.3s)
    -- Generating done (0.3s)
    -- Build files have been written to: /__w/bitcoin-core-nightly/bitcoin-core-nightly/bld
    
  3. maflcko commented at 4:42 PM on May 13, 2026: member

    Also inside a fresh podman run -i -t --rm archlinux:latest this passes:

    # history 
        1  pacman --noconfirm -Syu e2fsprogs cmake git gcc make python3 boost libevent zeromq ccache qt6 qrencode capnproto 
        2  git clone https://github.com/bitcoin/bitcoin.git --branch=31.x  --depth=1 ./b-c && cd b-c 
        3  cmake -B bld     --preset=dev-mode     -DAPPEND_CXXFLAGS="-Wno-error=stringop-overflow -Wno-error=sfinae-incomplete"     -DCMAKE_COMPILE_WARNING_AS_ERROR=ON     -DWITH_CCACHE=ON
        4  cmake --build ./bld -j $(nproc) 
    
    # git log -1 --oneline | cat
    24bfb2c Merge bitcoin/bitcoin#35210: [31.x] validation: correct lifetime of precomputed tx data
    
    # ./bld/bin/test_bitcoin -t cluster_linearize_tests
    Running 2 test cases...
    
    *** No errors detected
    
  4. 1-21gigasats commented at 5:07 PM on May 13, 2026: none

    Steps to reproduce:

    1. Make sure you have the latest packages installed, including the base tools required by makepkg:

      pacman -Syu base-devel
      

      My gcc version was 16.1.1+r12+g301eb08fa2c5-1.

    2. Clone the patched PKGBUILD with the required boost-1.91 fix:

      git clone --branch boost-1.91-python-checkdepends --single-branch https://gitlab.archlinux.org/tuxxx/bitcoin.git
      
    3. Run makepkg -s inside the checkout directory containing the PKGBUILD:

      makepkg -s
      

    Output should be like this (truncated to the interesting part):

    [...]
    
    [100%] Linking CXX executable ../../bin/test_bitcoin
    [100%] Built target test_bitcoin
    ==> Starting check()...
    Test project /home/builduser/bitcoin/src/bitcoin-31.0/build
    
    [...]
            Start  30: chainstate_write_tests
     30/157 Test  [#30](/github-metadata-backup-bitcoin-bitcoin/30/): chainstate_write_tests ...............   Passed    0.22 sec
            Start  31: checkqueue_tests
     31/157 Test  [#31](/github-metadata-backup-bitcoin-bitcoin/31/): checkqueue_tests .....................   Passed    0.77 sec
            Start  32: cluster_linearize_tests
     32/157 Test  [#32](/github-metadata-backup-bitcoin-bitcoin/32/): cluster_linearize_tests ..............***Exception: SegFault  0.25 sec
            Start  33: coins_tests_base
     33/157 Test  [#33](/github-metadata-backup-bitcoin-bitcoin/33/): coins_tests_base .....................   Passed    2.12 sec
            Start  34: coins_tests_dbbase
     34/157 Test  [#34](/github-metadata-backup-bitcoin-bitcoin/34/): coins_tests_dbbase ...................   Passed    3.80 sec
     
    [...]
     
     99% tests passed, 1 tests failed out of 157
    
    Total Test time (real) = 141.56 sec
    
    The following tests did not run:
             93 - script_assets_tests (Skipped)
    
    The following tests FAILED:
             32 - cluster_linearize_tests (SEGFAULT)
    Errors while running CTest
    Output from these tests are in: /home/builduser/bitcoin/src/bitcoin-31.0/build/Testing/Temporary/LastTest.log
    Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
    ==> ERROR: A failure occurred in check().
        Aborting...
    
  5. maflcko commented at 5:28 PM on May 13, 2026: member

    Ok, so you are compiling with LTO?

    bitcoin ............................. ON
      bitcoind ............................ ON
      bitcoin-node (multiprocess) ......... ON
      bitcoin-qt (GUI) .................... ON
      bitcoin-gui (GUI, multiprocess) ..... ON
      bitcoin-cli ......................... ON
      bitcoin-tx .......................... ON
      bitcoin-util ........................ ON
      bitcoin-wallet ...................... ON
      bitcoin-chainstate (experimental) ... ON
      libbitcoinkernel (experimental) ..... ON
      kernel-test (experimental) .......... ON
    Optional features:
      wallet support ...................... ON
      external signer ..................... ON
      ZeroMQ .............................. OFF
      IPC ................................. ON
      Embedded ASMap ...................... ON
      USDT tracing ........................ OFF
      QR code (GUI) ....................... ON
      DBus (GUI) .......................... ON
    Tests:
      test_bitcoin ........................ ON
      test_bitcoin-qt ..................... ON
      bench_bitcoin ....................... OFF
      fuzz binary ......................... OFF
    
    Cross compiling ....................... FALSE
    C++ compiler .......................... GNU 16.1.1, /usr/bin/c++
    CMAKE_BUILD_TYPE ...................... None
    Preprocessor defined macros ........... 
    C++ compiler flags .................... -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/home/username/b/src=/usr/src/debug/bitcoin -flto=auto -std=c++20 -fPIC -fno-extended-identifiers -fmacro-prefix-map=/home/username/b/src/bitcoin-31.0/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wleading-whitespace=spaces -Wtrailing-whitespace=any -Wno-unused-parameter
    Linker flags .......................... -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/home/username/b/src=/usr/src/debug/bitcoin -flto=auto -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now  -Wl,-z,pack-relative-relocs -flto=auto -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
    
    NOTE: The summary above may not exactly match the final applied build flags
          if any additional CMAKE_* or environment variables have been modified.
          To see the exact flags applied, build with the --verbose option.
    
    Treat compiler warnings as errors ..... OFF
    Use ccache for compiling .............. OFF
    

    I'd recommend against that, because GCC 16 will ICE with LTO, see also

    https://github.com/maflcko/bitcoin-core-nightly/actions/runs/25418679039/job/74555598580#step:10:712

    during IPA pass: cp
    lto1: internal compiler error: in decide_about_value, at ipa-cp.cc:6076
    /opt/gcc-latest/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto1 -quiet -dumpbase ../bin/bitcoind.wpa -msse4.2 -msse4.1 -mavx -mavx2 -msse4 -msha -mtune=generic -march=x86-64-v2 -g -g3 -O3 -O3 -O0 -fno-openmp -fno-openacc -fcf-protection=full -ftrapv -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -fPIE -fltrans-output-list=/tmp/ccX1CqWG.ltrans.out -fwpa=jobserver -fresolution=/tmp/cc5r6uf7.res -flinker-output=pie @/tmp/cceVZUcv
    Please submit a full bug report, with preprocessed source (by using -freport-bug).
    See <https://gcc.gnu.org/bugzilla> for instructions.
    lto-wrapper: fatal error: /opt/gcc-latest/bin/g++ returned 1 exit status
    compilation terminated.
    /usr/bin/ld.bfd: error: lto-wrapper failed
    collect2: error: ld returned 1 exit status
    gmake[2]: *** [src/CMakeFiles/bitcoind.dir/build.make:136: bin/bitcoind] Error 1
    gmake[1]: *** [CMakeFiles/Makefile2:1189: src/CMakeFiles/bitcoind.dir/all] Error 2
    gmake[1]: *** Waiting for unfinished jobs....
    during IPA pass: cp
    lto1: internal compiler error: in decide_about_value, at ipa-cp.cc:6076
    /opt/gcc-latest/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto1 -quiet -dumpbase ../bin/bitcoin-node.wpa -msse4.2 -msse4.1 -mavx -mavx2 -msse4 -msha -mtune=generic -march=x86-64-v2 -g -g3 -O3 -O3 -O0 -fno-openmp -fno-openacc -fcf-protection=full -ftrapv -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -fPIE -fltrans-output-list=/tmp/ccMxBG8j.ltrans.out -fwpa=jobserver -fresolution=/tmp/ccoc2zb2.res -flinker-output=pie @/tmp/ccUTOgd0
    Please submit a full bug report, with preprocessed source (by using -freport-bug).
    See <https://gcc.gnu.org/bugzilla> for instructions.
    lto-wrapper: fatal error: /opt/gcc-latest/bin/g++ returned 1 exit status
    compilation terminated.
    /usr/bin/ld.bfd: error: lto-wrapper failed
    collect2: error: ld returned 1 exit status
    gmake[2]: *** [src/CMakeFiles/bitcoin-node.dir/build.make:142: bin/bitcoin-node] Error 1
    gmake[1]: *** [CMakeFiles/Makefile2:1235: src/CMakeFiles/bitcoin-node.dir/all] Error 2
    
  6. loqs commented at 5:56 PM on May 13, 2026: none

    I'd recommend against that, because GCC 16 will ICE with LTO, see also

    The ICE is not reproducible with Arch's gcc 16.1.1+r12+g301eb08fa2c5. The test still fails with LTO disabled. Disabling all CXXFLAGS allows it to pass. Arch's standard CXXFLAGS are -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/bitcoin/src=/usr/src/debug/bitcoin -flto=auto

  7. maflcko commented at 6:36 PM on May 13, 2026: member

    Ok, I see. I just have difficulty reproducing this outside the makepkg -s. For example, the following passes for me:

    cmake   -B bld -DCMAKE_BUILD_TYPE=None             -DCMAKE_COMPILE_WARNING_AS_ERROR=ON     -DWITH_CCACHE=ON -DAPPEND_CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -flto=auto"   -DAPPEND_CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -flto=auto"   -DAPPEND_LDFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto"
    

    Can you please share exact steps to reproduce in the form:

    git checkout commit_id
    cmake -B bld  ...bla...
    cmake --build ./bld -j $(nproc) 
    ./bld/bin/test_bitcoin -t cluster_linearize_tests
    
  8. loqs commented at 6:44 PM on May 13, 2026: none

    The issue is triggered on gcc 16.1 by CXXFLAGS containing -Wp,-D_GLIBCXX_ASSERTIONS. The additional run time checking would catch an out of bounds access which matches with the proposed fix addressing such an issue.

  9. loqs commented at 11:05 PM on May 13, 2026: none

    Minimal reproducer using current git HEAD as of writing:

    git clone https://github.com/bitcoin/bitcoin
    cd bitcoin
    git checkout c680cfe343647f36f97c5ab1d70ecf6981cd1d75
    export CXXFLAGS="-Wp,-D_GLIBCXX_ASSERTIONS"
    cmake -B bld -S .
    cmake --build ./bld -j $(nproc)
    ./bld/bin/test_bitcoin -t cluster_linearize_tests
    ....
    Running 2 test cases...
    unknown location(0): fatal error: in "cluster_linearize_tests/depgraph_optimal_tests": memory access violation at address: 0x7ffe97af156e: no mapping at fault address
    ./test/cluster_linearize_tests.cpp(101): last checkpoint
    
    *** 1 failure is detected in the test module "Bitcoin Core Test Suite"
    

    Full log bitcoin.log

  10. maflcko commented at 1:25 PM on May 14, 2026: member

    Minimal reproducer using current git HEAD as of writing:

    Thanks, exact steps to reproduce help. Now I can reproduce on other distros as well. E.g Debian/Ubuntu/Fedora:

    root@3b7ff3e97f62:/b-c# cmake -B bld-gcc-16 -S . -DCMAKE_CXX_COMPILER='g++-16;-D_GLIBCXX_ASSERTIONS' -DCMAKE_C_COMPILER='gcc-16' -DENABLE_WALLET=OFF -DENABLE_IPC=OFF 
    -- Checking for required C++ features
    -- Checking for required C++ features - done
    -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE dot) 
    
    Configuring secp256k1 subtree...
    -- Could NOT find Valgrind (missing: Valgrind_INCLUDE_DIR Valgrind_WORKS) 
    
    
    secp256k1 configure summary
    ===========================
    Build artifacts:
      library type ........................ Static
    Optional modules:
      ECDH ................................ OFF
      ECDSA pubkey recovery ............... ON
      extrakeys ........................... ON
      schnorrsig .......................... ON
      musig ............................... ON
      ElligatorSwift ...................... ON
    Parameters:
      ecmult window size .................. 15
      ecmult gen table size ............... 86 KiB
    Optional features:
      assembly ............................ x86_64
      external callbacks .................. OFF
    Optional binaries:
      benchmark ........................... OFF
      noverify_tests ...................... ON
      tests ............................... ON
      exhaustive tests .................... ON
      ctime_tests ......................... OFF
      examples ............................ OFF
    
    Cross compiling ....................... FALSE
    API visibility attributes ............. OFF
    Valgrind .............................. OFF
    Preprocessor defined macros ........... ECMULT_WINDOW_SIZE=15 COMB_BLOCKS=43 COMB_TEETH=6 USE_ASM_X86_64=1
    C compiler ............................ GNU 16.0.1, /usr/bin/gcc-16
    CFLAGS ................................ 
    Compile options ....................... -Wall -pedantic -Wcast-align -Wcast-align=strict -Wextra -Wleading-whitespace=spaces -Wnested-externs -Wno-long-long -Wno-overlength-strings -Wno-unused-function -Wshadow -Wstrict-prototypes -Wtrailing-whitespace=any -Wundef
    Build type:
     - CMAKE_BUILD_TYPE ................... RelWithDebInfo
     - CFLAGS ............................. -O2 -g 
     - LDFLAGS for executables ............ 
     - LDFLAGS for shared libraries ....... 
    
    
    
    Configure summary
    =================
    Executables:
      bitcoin ............................. ON
      bitcoind ............................ ON
      bitcoin-node (multiprocess) ......... OFF
      bitcoin-qt (GUI) .................... OFF
      bitcoin-gui (GUI, multiprocess) ..... OFF
      bitcoin-cli ......................... ON
      bitcoin-tx .......................... ON
      bitcoin-util ........................ ON
      bitcoin-wallet ...................... OFF
      bitcoin-chainstate (experimental) ... OFF
      libbitcoinkernel (experimental) ..... OFF
      kernel-test (experimental) .......... OFF
    Optional features:
      wallet support ...................... OFF
      external signer ..................... ON
      ZeroMQ .............................. OFF
      IPC ................................. OFF
      Embedded ASMap ...................... ON
      USDT tracing ........................ OFF
      QR code (GUI) ....................... OFF
      DBus (GUI) .......................... OFF
    Tests:
      test_bitcoin ........................ ON
      test_bitcoin-qt ..................... OFF
      bench_bitcoin ....................... OFF
      fuzz binary ......................... OFF
    
    Cross compiling ....................... FALSE
    C++ compiler .......................... GNU 16.0.1, /usr/bin/g++-16
    CMAKE_BUILD_TYPE ...................... RelWithDebInfo
    Preprocessor defined macros ........... 
    C++ compiler flags .................... -D_GLIBCXX_ASSERTIONS -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fmacro-prefix-map=/b-c/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wleading-whitespace=spaces -Wtrailing-whitespace=any -Wno-unused-parameter
    Linker flags .......................... -O2 -g -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
    
    NOTE: The summary above may not exactly match the final applied build flags
          if any additional CMAKE_* or environment variables have been modified.
          To see the exact flags applied, build with the --verbose option.
    
    Treat compiler warnings as errors ..... OFF
    Use ccache for compiling .............. ON
    
    
    -- Configuring done (2.7s)
    -- Generating done (0.6s)
    -- Build files have been written to: /b-c/bld-gcc-16
    
    
    
    root@3b7ff3e97f62:/b-c# cmake --build ./bld-gcc-16/ -j $(nproc) --target=test_bitcoin && ./bld-gcc-16/bin/test_bitcoin -t cluster_linearize_tests 
    [  1%] Built target crc32c
    [  1%] Generating bitcoin-build-info.h
    [  1%] Built target secp256k1_precomputed
    [  6%] Built target minisketch
    [  8%] Built target univalue
    [  9%] Built target bitcoin_cli
    [ 17%] Built target bitcoin_crypto
    [ 20%] Built target bitcoin_consensus
    [ 22%] Built target secp256k1
    [ 25%] Built target test_util
    [ 38%] Built target leveldb
    [ 38%] Built target generate_build_info
    [ 38%] Built target bitcoin_clientversion
    [ 48%] Built target bitcoin_util
    [ 64%] Built target bitcoin_common
    [ 95%] Built target bitcoin_node
    [100%] Built target test_bitcoin
    Running 2 test cases...
    unknown location(0): fatal error: in "cluster_linearize_tests/depgraph_optimal_tests": memory access violation at address: 0x7fff7c2a5e5e: no mapping at fault address
    ./test/cluster_linearize_tests.cpp(101): last checkpoint
    
    *** 1 failure is detected in the test module "Bitcoin Core Test Suite"
    
  11. maflcko commented at 1:32 PM on May 14, 2026: member

    I went ahead and manually converted the failing test into a stand-alone cpp file with a main function:

    <details><summary>cpp file</summary>

    # cat ./src/bitcoind.cpp 
    // Copyright (c) 2009-2010 Satoshi Nakamoto
    // Copyright (c) 2009-present The Bitcoin Core developers
    // Distributed under the MIT software license, see the accompanying
    // file COPYING or http://www.opensource.org/licenses/mit-license.php.
    
    #include <util/check.h>
    #include <cluster_linearize.h>
    #include <test/util/cluster_linearize.h>
    #include <util/bitset.h>
    //#include <util/strencodings.h>
    
    #include <vector>
    #include <random>
    
    //#include <util/translation.h> 
    //
    #include <functional>
    using TranslateFn = std::function<std::string(const char*)>;
    const extern TranslateFn G_TRANSLATION_FUN;
    const TranslateFn G_TRANSLATION_FUN{nullptr};
    
    
    
    using namespace cluster_linearize;
    using namespace util::hex_literals;
    
    namespace {
    
    /** Special magic value that indicates to TestDepGraphSerialization that a cluster entry represents
     *  a hole. */
    constexpr std::pair<FeeFrac, TestBitSet> HOLE{FeeFrac{0, 0x3FFFFF}, {}};
    
    template<typename SetType>
    void TestDepGraphSerialization(const std::vector<std::pair<FeeFrac, SetType>>& cluster, const std::string& hexenc)
    {
        // Construct DepGraph from cluster argument.
        DepGraph<SetType> depgraph;
        SetType holes;
        for (DepGraphIndex i = 0; i < cluster.size(); ++i) {
            depgraph.AddTransaction(cluster[i].first);
            if (cluster[i] == HOLE) holes.Set(i);
        }
        for (DepGraphIndex i = 0; i < cluster.size(); ++i) {
            depgraph.AddDependencies(cluster[i].second, i);
        }
        depgraph.RemoveTransactions(holes);
        SanityCheck(depgraph);
    
        // There may be multiple serializations of the same graph, but DepGraphFormatter's serializer
        // only produces one of those. Verify that hexenc matches that canonical serialization.
        std::vector<unsigned char> encoding;
        VectorWriter writer(encoding, 0);
        writer << Using<DepGraphFormatter>(depgraph);
        assert(HexStr(encoding)== hexenc);
    
        // Test that deserializing that encoding yields depgraph. This is effectively already implied
        // by the round-trip test above (if depgraph is acyclic), but verify it explicitly again here.
        SpanReader reader(encoding);
        DepGraph<SetType> depgraph_read;
        reader >> Using<DepGraphFormatter>(depgraph_read);
        assert(depgraph == depgraph_read);
    }
    
    void TestOptimalLinearization(std::span<const uint8_t> enc, std::initializer_list<DepGraphIndex> optimal_linearization)
    {
        DepGraphIndex tx_count = 0;
        //FastRandomContext rng;
    std::mt19937_64 rng{std::random_device{}()};
    
        auto test_fn = [&]<typename SetType>() {
            DepGraph<SetType> depgraph;
            SpanReader reader(enc);
            reader >> Using<DepGraphFormatter>(depgraph);
            SanityCheck(depgraph);
            std::vector<DepGraphIndex> lin;
            for (int iter = 0; iter < 200; ++iter) {
                bool opt;
                uint64_t cost{0};
                bool is_topological{true};
                switch (int{std::uniform_int_distribution<int> {0, 3}(rng)}) {
                case 0:
                    // Use empty input linearization.
                    lin.clear();
                    break;
                case 1:
                    // Reuse previous optimal linearization as input.
                    break;
                case 2:
                    // Construct random valid input linearization.
                    std::shuffle(lin.begin(), lin.end(), rng);
                    std::sort(lin.begin(), lin.end(), [&](auto a, auto b) { return depgraph.Ancestors(a).Count() < depgraph.Ancestors(b).Count(); });
                    break;
                case 3:
                    // Construct random potentially invalid input linearization.
                    std::shuffle(lin.begin(), lin.end(), rng);
                    is_topological = false;
                    break;
                }
                std::tie(lin, opt, cost) = Linearize(
                    /*depgraph=*/depgraph,
                    /*max_cost=*/1000000000000,
                    /*rng_seed=*/rng(),
                    /*fallback_order=*/IndexTxOrder{},
                    /*old_linearization=*/lin,
                    /*is_topological=*/is_topological);
                assert(opt);
                assert(cost <= MaxOptimalLinearizationCost(depgraph.TxCount()));
                SanityCheck(depgraph, lin);
                assert(std::ranges::equal(lin, optimal_linearization));
            }
            tx_count = depgraph.PositionRange();
        };
    
        // Always run with 64-bit set types
        // - The native one that will be used on this platform.
        test_fn.template operator()<BitSet<64>>();
        // - The one used on 32-bit platforms.
        test_fn.template operator()<bitset_detail::MultiIntBitSet<uint32_t, 2>>();
        // - An 8-bit one, which is maximally different in terms of bitset behavior.
        test_fn.template operator()<bitset_detail::MultiIntBitSet<uint8_t, 8>>();
    
        // Also run with 32-bit set types if the cluster doesn't use indexes above 31.
        if (tx_count <= 32) {
            // - The native one that will be used on this platform.
            test_fn.template operator()<BitSet<32>>();
            // - An 8-bit one, which is maximally different in terms of bitset behavior.
            test_fn.template operator()<bitset_detail::MultiIntBitSet<uint8_t, 4>>();
        }
    }
    
    } // namespace
    
    
    
    int main()
    {
        TestOptimalLinearization("8540e74000833180831801875dd14e00000000"_hex_u8, {1, 0, 2});
    }
    

    </details>

    I preprocessed that with gcc 15 (g++-15 -E -P ...) and then ran cvise with the following bash script.

    <details><summary>cvise bash script</summary>

    #!/bin/bash
    
    # filename passed to cvise
    SOURCE_FILE="work.ii"
    OUTPUT_EXE="./tmp_exe"
    
    # Compilers
    GCC15="ccache g++-15"
    GCC16="ccache g++-16"
    
    # Minimum necessary args for the bug to manifest
    COMMON_ARGS="-O2 -std=c++20 -g0      -Werror=return-type -Werror=uninitialized -Werror=array-bounds"
    
    # --- Step 2: Compile and Run with GCC 15 (The Reference Version) ---
    if ! $GCC15 $COMMON_ARGS -o $OUTPUT_EXE "$SOURCE_FILE" ; then
        echo "Compilation failed with GCC 15. Undo the last change."
        exit 1
    fi
    
    valgrind --tool=none --error-exitcode=43 --exit-on-first-error=yes "$OUTPUT_EXE"
    EXIT_CODE=$?
    if [ $EXIT_CODE -ne 0 ]; then
        echo "FAILURE: GCC 15 returned $EXIT_CODE (Expected 0). Undo the last change."
        exit 1
    fi
    
    # --- Step 1: Compile and Run with GCC 16 (The Buggy Version) ---
    if ! $GCC16 $COMMON_ARGS -o $OUTPUT_EXE "$SOURCE_FILE" ; then
        echo "Compilation failed with GCC 16. Undo the last change."
        exit 1
    fi
    
    valgrind --tool=none --error-exitcode=43 --exit-on-first-error=yes "$OUTPUT_EXE" 
    EXIT_CODE=$?
    if [ $EXIT_CODE -ne 139 ]; then
        echo "FAILURE: GCC 16 returned $EXIT_CODE (Expected segfault). Undo the last change."
        exit 1
    fi
    
    # --- Success ---
    echo "All validation steps complete. Continue with the next change"
    exit 0
    

    </details>

  12. maflcko commented at 8:31 PM on May 15, 2026: member

    Hmm, cvise didn't work well on the .ii file (ended up in an ugly hole). Instead manually reduced the .cc file to https://godbolt.org/z/331jPdvcW so far.

  13. maflcko added the label Upstream on May 16, 2026
  14. maflcko commented at 7:09 AM on May 16, 2026: member

    See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125345

    Not sure how to best work around this. Can you use GCC 15 for now? Or use GCC 16 with -O1?

  15. 1-21gigasats commented at 9:20 AM on May 16, 2026: none

    Thanks for all your hard work @maflcko - I have passed the question to the maintainer as I don't have the technical background to answer it. But we aren't probably in a hurry right now as we have a working package for v31 out, as long as it does not need any rebuild.

  16. 1-21gigasats commented at 11:32 AM on May 16, 2026: none

    Arch Package Maintainer decided to rebuild the package using gcc15 and the boost1.91 patch here - do you want to leave this issue open @maflcko to track the upstream issue?

  17. maflcko commented at 12:30 PM on May 16, 2026: member

    It affects all GCC 16 compilations (see #35282 (comment)), so I think it can be left open for now, and "Arch Linux" can be removed from the title.

  18. fanquake renamed this:
    cluster_linearize_tests fails with GCC 16 on Arch Linux
    cluster_linearize_tests fails with GCC 16
    on May 16, 2026
  19. DrahtBot renamed this:
    cluster_linearize_tests fails with GCC 16
    cluster_linearize_tests fails with GCC 16.1 (fixed in GCC 16.2)
    on May 17, 2026

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: 2026-05-19 06:51 UTC