test: consider Clang type sanitizer #32495

issue fanquake openend this issue on May 14, 2025
  1. fanquake commented at 11:42 am on May 14, 2025: member

    Clang 20 introduced an experimental type sanitizer that “detects violations of C/C++ type-based aliasing rules.” See here for more info: https://clang.llvm.org/docs/TypeSanitizer.html. Someone might want to run this against our code, to see if it works, or detects real issues. This could likely be done with:

    0make -C depends/ CC=clang CXX=clang++ CXXFLAGS="-stdlib=libc++" NM=llvm-nm AR=llvm-ar RANLIB=llvm-ranlib STRIP=llvm-strip
    1cmake -B build --toolchain /bitcoin/depends/x86_64-pc-linux-gnu/toolchain.cmake -DSANITIZERS=type
    2cmake --build build
    
    0# ./build/bin/bitcoind
    1==20420==ERROR: TypeSanitizer: type-aliasing-violation on address 0x5d65ea902120 (pc 0x5d65e334066b bp 0x7ffe26be2d50 sp 0x7ffe26be2ce0 tid 20420)
    2WRITE of size 8 at 0x5d65ea902120 with type p1 _ZTSNSt3__110__function6__baseIFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPKcEEE (in std::__1::__function::__value_func<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (char const*)> at offset 32) accesses part of an existing object of type std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (char const*)> that starts at offset -32
    3    [#0](/bitcoin-bitcoin/0/) 0x5d65e334066a in std::__1::__function::__value_func<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (char const*)>::__value_func[abi:ne200100]() /usr/lib/llvm-20/bin/../include/c++/v1/__functional/function.h:355:52
    4    [#1](/bitcoin-bitcoin/1/) 0x5d65e334066a in std::__1::function<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (char const*)>::function[abi:ne200100](std::nullptr_t) /usr/lib/llvm-20/bin/../include/c++/v1/__functional/function.h:862:25
    5    [#2](/bitcoin-bitcoin/2/) 0x5d65e334066a in __cxx_global_var_init.1 /bitcoin/build/src/./bitcoind.cpp:37:19
    6    [#3](/bitcoin-bitcoin/3/) 0x5d65e334066a in _GLOBAL__sub_I_bitcoind.cpp /bitcoin/build/src/./bitcoind.cpp
    
  2. fanquake added the label Tests on May 15, 2025


fanquake

Labels
Tests


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

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