windows: build failure with GCC 14.2 & -D_GLIBCXX_DEBUG #31436

issue fanquake openend this issue on December 6, 2024
  1. fanquake commented at 11:38 am on December 6, 2024: member

    Initially seen building using depends & DEBUG=1, which adds -D_GLIBCXX_DEBUG.

     0# x86_64-w64-mingw32-g++ (GCC) 14.2.0 on Alpine x86_64
     1make -C depends/ HOST=x86_64-w64-mingw32 -j12 NO_QT=1 NO_ZMQ=1 NO_WALLET=1
     2cmake -B build --toolchain /bitcoin/depends/x86_64-w64-mingw32/toolchain.cmake -DAPPEND_CPPFLAGS="-D_GLIBCXX_DEBUG"
     3cmake --build build
     4<snip>
     5[ 25%] Building CXX object src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.obj
     6cd /bitcoin/build/src && /usr/bin/ccache /usr/bin/x86_64-w64-mingw32-g++ -DNOMINMAX -DSECP256K1_STATIC -DWIN32 -DWIN32_LEAN_AND_MEAN -D_MT -D_WIN32_IE=0x0A00 -D_WIN32_WINNT=0x0A00 -D_WINDOWS [@CMakeFiles](/bitcoin-bitcoin/contributor/cmakefiles/)/bitcoin_consensus.dir/includes_CXX.rsp -pipe -std=c++20 -O2 -O2 -g -std=c++20 -Wa,-muse-unaligned-vector-move -fno-extended-identifiers -fdebug-prefix-map=/bitcoin/src=. -fmacro-prefix-map=/bitcoin/src=. -fstack-reuse=none -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 -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -MD -MT src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.obj -MF CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.obj.d -o CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.obj -c /bitcoin/src/pubkey.cpp -D_GLIBCXX_DEBUG
     7In file included from /usr/x86_64-w64-mingw32/include/c++/14.2.0/debug/debug.h:90,
     8                 from /usr/x86_64-w64-mingw32/include/c++/14.2.0/bits/stl_algobase.h:69,
     9                 from /usr/x86_64-w64-mingw32/include/c++/14.2.0/string:51,
    10                 from /bitcoin/src/crypto/sha256.h:10,
    11                 from /bitcoin/src/hash.h:12,
    12                 from /bitcoin/src/pubkey.h:10,
    13                 from /bitcoin/src/pubkey.cpp:6:
    14/bitcoin/src/pubkey.cpp:195:116:   in 'constexpr' expansion of 'std::span<const unsigned char>(util::hex_literals::operator""_hex_u8<util::detail::Hex<65>{std::array<std::byte, 32>{std::__array_traits<std::byte, 32>::_Type{(std::byte)80, (std::byte)146, (std::byte)155, (std::byte)116, (std::byte)193, (std::byte)160, (std::byte)73, (std::byte)84, (std::byte)183, (std::byte)139, (std::byte)75, (std::byte)96, (std::byte)53, (std::byte)233, (std::byte)122, (std::byte)94, (std::byte)7, (std::byte)138, (std::byte)90, (std::byte)15, (std::byte)40, (std::byte)236, (std::byte)150, (std::byte)213, (std::byte)71, (std::byte)191, (std::byte)238, (std::byte)154, (std::byte)206, (std::byte)128, (std::byte)58, (std::byte)192}}}>())'
    15/usr/x86_64-w64-mingw32/include/c++/14.2.0/span:202:57:   in 'constexpr' expansion of '((std::span<const unsigned char>*)this)->std::span<const unsigned char>::span<const unsigned char*>((& __arr)->std::array<unsigned char, 32>::data(), 32)'
    16/usr/x86_64-w64-mingw32/include/c++/14.2.0/span:165:11: error: '__builtin_expect(((long int)(! __gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count))))), 0)' is not a constant expression
    17  165 |           __glibcxx_requires_valid_range(__first, __first + __count);
    18      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    19gmake[2]: *** [src/CMakeFiles/bitcoin_consensus.dir/build.make:170: src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.obj] Error 1
    
  2. smokeytempo commented at 12:00 pm on December 6, 2024: none

    You can remove the _GLIBCXX_DEBUG using:

    cmake -B build –toolchain /bitcoin/depends/x86_64-w64-mingw32/toolchain.cmake cmake –build build

    or:

    downgrade the version of GCC, well upgrade or downgrade

    or:

    Use alternative debugging tools

    or lastly:

    Isolate the debugging build from the production one to ensure no errors

  3. maflcko commented at 1:37 pm on December 9, 2024: member

    Possible workaround:

     0diff --git a/src/pubkey.cpp b/src/pubkey.cpp
     1index 0849d2a..a02c6e6 100644
     2--- a/src/pubkey.cpp
     3+++ b/src/pubkey.cpp
     4@@ -192,7 +192,8 @@ int ecdsa_signature_parse_der_lax(secp256k1_ecdsa_signature* sig, const unsigned
     5  *  For an example script for calculating H, refer to the unit tests in
     6  *  ./test/functional/test_framework/crypto/secp256k1.py
     7  */
     8-constexpr XOnlyPubKey XOnlyPubKey::NUMS_H{"50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"_hex_u8};
     9+constexpr auto val{"50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"_hex_u8};
    10+constexpr XOnlyPubKey XOnlyPubKey::NUMS_H{val};
    11 
    12 std::vector<CKeyID> XOnlyPubKey::GetKeyIDs() const
    13 {
    

    Minimal reproducer https://godbolt.org/z/E4YafE9Pd:

    0#include <array>
    1#include <span>
    2
    3struct A {
    4    constexpr A(std::span<const unsigned char>) {}
    5};
    6constexpr A val{std::array<unsigned char, 2>{0x11, 0x22}};
    
  4. maflcko added the label Build system on Dec 9, 2024
  5. maflcko added the label Upstream on Dec 9, 2024
  6. maflcko commented at 2:40 pm on December 9, 2024: member
  7. maflcko commented at 7:58 am on December 10, 2024: member

    This will also start hitting in CI, with:

     0diff --git a/ci/test/00_setup_env_native_previous_releases.sh b/ci/test/00_setup_env_native_previous_releases.sh
     1index 19a33f1..8b17e3b 100755
     2--- a/ci/test/00_setup_env_native_previous_releases.sh
     3+++ b/ci/test/00_setup_env_native_previous_releases.sh
     4@@ -8,9 +8,9 @@ export LC_ALL=C.UTF-8
     5 
     6 export CONTAINER_NAME=ci_native_previous_releases
     7 export CI_IMAGE_NAME_TAG="docker.io/ubuntu:22.04"
     8-# Use minimum supported python3.10 and gcc-11, see doc/dependencies.md
     9-export PACKAGES="gcc-11 g++-11 python3-zmq"
    10-export DEP_OPTS="DEBUG=1 CC=gcc-11 CXX=g++-11"
    11+# Use minimum supported python3.10 and gcc-12, see doc/dependencies.md
    12+export PACKAGES="gcc-12 g++-12 python3-zmq"
    13+export DEP_OPTS="DEBUG=1 CC=gcc-12 CXX=g++-12"
    14 export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude feature_dbcrash"  # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash
    15 export RUN_UNIT_TESTS_SEQUENTIAL="true"
    16 export RUN_UNIT_TESTS="false"
    
     0[  4%] Building CXX object src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o
     1cd /ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src && /usr/bin/ccache /usr/bin/g++-12 -DABORT_ON_FAILED_ASSUME -DDEBUG -DDEBUG_LOCKCONTENTION -DDEBUG_LOCKORDER -DRPC_DOC_CHECK -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -I/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src -I/ci_container_base/src -I/ci_container_base/src/secp256k1/include -funsigned-char -g0 -O2 -fPIC -fvisibility=hidden -fno-extended-identifiers -fdebug-prefix-map=/ci_container_base/src=. -fmacro-prefix-map=/ci_container_base/src=. -fstack-reuse=none -Werror -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 -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -std=c++20 -MD -MT src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o -MF CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o.d -o CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o -c /ci_container_base/src/pubkey.cpp -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE 
     2In file included from /usr/include/c++/12/debug/stl_iterator.h:32,
     3                 from /usr/include/c++/12/bits/stl_iterator.h:2623,
     4                 from /usr/include/c++/12/string:47,
     5                 from /ci_container_base/src/crypto/sha256.h:10,
     6                 from /ci_container_base/src/hash.h:12,
     7                 from /ci_container_base/src/pubkey.h:10,
     8                 from /ci_container_base/src/pubkey.cpp:6:
     9/ci_container_base/src/pubkey.cpp:195:116:   in constexpr expansion of std::span<const unsigned char>(util::hex_literals::operator""_hex_u8<util::detail::Hex<65>{std::array<std::byte, 32>{std::__array_traits<std::byte, 32>::_Type{(std::byte)80, (std::byte)146, (std::byte)155, (std::byte)116, (std::byte)193, (std::byte)160, (std::byte)73, (std::byte)84, (std::byte)183, (std::byte)139, (std::byte)75, (std::byte)96, (std::byte)53, (std::byte)233, (std::byte)122, (std::byte)94, (std::byte)7, (std::byte)138, (std::byte)90, (std::byte)15, (std::byte)40, (std::byte)236, (std::byte)150, (std::byte)213, (std::byte)71, (std::byte)191, (std::byte)238, (std::byte)154, (std::byte)206, (std::byte)128, (std::byte)58, (std::byte)192}}}>())
    10/usr/include/c++/12/span:200:57:   in constexpr expansion of ((std::span<const unsigned char>*)this)->std::span<const unsigned char>::span<const unsigned char*>((& __arr)->std::array<unsigned char, 32>::data(), 32)
    11/usr/include/c++/12/span:163:4:   in constexpr expansion of __gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count)))
    12/usr/include/c++/12/debug/helper_functions.h:257:31:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (_Integral(), _Integral()))
    13/usr/include/c++/12/debug/helper_functions.h:189:31:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::__iterator_category<const unsigned char*>(__first), std::iterator_traits<const unsigned char*>::iterator_category()))
    14/usr/include/c++/12/debug/helper_functions.h:176:19:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::input_iterator_tag(), std::input_iterator_tag()))
    15/usr/include/c++/12/debug/helper_functions.h:136:20: error: (((std::array<unsigned char, 32>::const_pointer)(&<anonymous>.std::array<unsigned char, 32>::_M_elems)) == 0) is not a constant expression
    16  136 |     { return __ptr == 0; }
    17      |              ~~~~~~^~~~
    18gmake[2]: *** [src/CMakeFiles/bitcoin_consensus.dir/build.make:160: src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o] Error 1
    19gmake[2]: Leaving directory '/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu'
    20gmake[1]: *** [CMakeFiles/Makefile2:786: src/CMakeFiles/bitcoin_consensus.dir/all] Error 2
    21gmake[1]: Leaving directory '/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu'
    22gmake: *** [Makefile:146: all] Error 2
    
  8. maflcko added the label Tests on Dec 10, 2024
  9. maflcko added the label CI failed on Dec 10, 2024
  10. maflcko commented at 7:18 am on December 12, 2024: member
    Fixed in gcc-15. There may be backports to 12-14, but I wouldn’t count on it.
  11. maflcko closed this on Dec 12, 2024

  12. maflcko commented at 11:20 am on December 17, 2024: member

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-12-21 15:12 UTC

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