Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM's memory sanitizer caught use of uninitialized value #2939

Open
ImmanuelHaffner opened this issue Nov 29, 2024 · 1 comment
Open

LLVM's memory sanitizer caught use of uninitialized value #2939

ImmanuelHaffner opened this issue Nov 29, 2024 · 1 comment

Comments

@ImmanuelHaffner
Copy link

ImmanuelHaffner commented Nov 29, 2024

Describe the bug
I build my code with Clang and LLVM's memory sanitizer. When running the tests, msan reports a use of an uninitialized value in the Catch2 code part.

Expected behavior
No use of uninitialized value. Perhaps it is a false positive, in which case it would be nice if you annotated the respective code segment accordingly.

Reproduction steps

I have a custom main():

#include <catch2/catch_session.hpp>
#include <clocale>
#include <iostream>

int main(int argc, char* argv[])
{
    std::setlocale(LC_ALL, "en_US.UTF-8");
    std::locale::global(std::locale("en_US.UTF-8"));
    std::cout.imbue(std::locale());
    int result = Catch::Session().run( argc, argv );
    return result;
}

I compile with -stdlib=libc++ -lc++abi -fsanitize=memory -fsanitize-link-c++-runtime.

Platform information:

  • OS: Linux IH-X1Carbon 6.10.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 x86_64 GNU/Linux
  • Compiler+version:
    clang version 18.0.0git (https://github.com/llvm/llvm-project.git 95e500808d96bece0edfedb70d9ecdf16c375656)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /usr/local/bin
    
  • Catch version: v3.7.1

Additional information
MSan trace

==6381==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x555555a0af26 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::pair<std::__cxx11::basic_string<char, std::char
_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_trait
s<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>>, Catch::Detail::CaseInsensitiveLess, std::allocator<std::pair<std::__cxx11::basi
c_string<char, std::char_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>>>::_S_right(std::_Rb_tree_node_base*) /usr/bin/../l
ib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/stl_tree.h:786:9
    #1 0x555555a0dec1 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::pair<std::__cxx11::basic_string<char, std::char
_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_trait
s<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>>, Catch::Detail::CaseInsensitiveLess, std::allocator<std::pair<std::__cxx11::basi
c_string<char, std::char_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>>>::_M_lower_bound(std::_Rb_tree_node<std::pair<std:
:__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>>*, std::_Rb_tree_node_base*, std::__c
xx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/stl_tre
e.h:1951:10
    #2 0x555555a0da34 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::pair<std::__cxx11::basic_string<char, std::char
_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_trait
s<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>>, Catch::Detail::CaseInsensitiveLess, std::allocator<std::pair<std::__cxx11::basi
c_string<char, std::char_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Catch::IReporterFactory>>>>::lower_bound(std::__cxx11::basic_string<char, std
::char_traits<char>, std::allocator<char>> const&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/stl_tree.h:1267:16
    #3 0x555555a0ca62 in std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Catch::Detail::unique_ptr<Catch::IReporterFactory>, Catch
::Detail::CaseInsensitiveLess, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Cat
ch::IReporterFactory>>>>::lower_bound(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2
.1/../../../../include/c++/14.2.1/bits/stl_map.h:1308:21
    #4 0x555555a01929 in std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Catch::Detail::unique_ptr<Catch::IReporterFactory>, Catch
::Detail::CaseInsensitiveLess, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, Catch::Detail::unique_ptr<Cat
ch::IReporterFactory>>>>::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../
../../../include/c++/14.2.1/bits/stl_map.h:529:17
    #5 0x5555559feec6 in Catch::ReporterRegistry::ReporterRegistry() /home/immanuel/Documents/mutable-org/mutable-db/build/DebugMSan/src/catch2/internal/catch_reporter_reg
istry.cpp:37:9
    #6 0x555555cd046d in Catch::(anonymous namespace)::RegistryHub::RegistryHub() /home/immanuel/Documents/mutable-org/mutable-db/build/DebugMSan/src/catch2/catch_registry
_hub.cpp:35:13
    #7 0x555555cd0150 in Catch::Singleton<Catch::(anonymous namespace)::RegistryHub, Catch::IRegistryHub, Catch::IMutableRegistryHub>::Singleton() /home/immanuel/Documents
/mutable-org/mutable-db/build/DebugMSan/src/catch2/../catch2/internal/catch_singletons.hpp:23:11
    #8 0x555555ccff09 in Catch::Singleton<Catch::(anonymous namespace)::RegistryHub, Catch::IRegistryHub, Catch::IMutableRegistryHub>::getInternal() /home/immanuel/Documen
ts/mutable-org/mutable-db/build/DebugMSan/src/catch2/../catch2/internal/catch_singletons.hpp:28:34
    #9 0x555555ccfce8 in Catch::Singleton<Catch::(anonymous namespace)::RegistryHub, Catch::IRegistryHub, Catch::IMutableRegistryHub>::getMutable() /home/immanuel/Document
s/mutable-org/mutable-db/build/DebugMSan/src/catch2/../catch2/internal/catch_singletons.hpp:39:21
    #10 0x555555ccfcd8 in Catch::getMutableRegistryHub() /home/immanuel/Documents/mutable-org/mutable-db/build/DebugMSan/src/catch2/catch_registry_hub.cpp:95:16
    #11 0x555555ad41b0 in Catch::AutoReg::AutoReg(Catch::Detail::unique_ptr<Catch::ITestInvoker>, Catch::SourceLineInfo const&, Catch::StringRef, Catch::NameAndTags const&
) /home/immanuel/Documents/mutable-org/mutable-db/build/DebugMSan/src/catch2/internal/catch_test_registry.cpp:71:13
    #12 0x5555555a91c3 in __cxx_global_var_init /home/immanuel/Documents/mutable-org/mutable-db/test/unittests/parse/LexerTest.cpp:19:1
    #13 0x5555555a9788 in _GLOBAL__sub_I_LexerTest.cpp /home/immanuel/Documents/mutable-org/mutable-db/test/unittests/parse/LexerTest.cpp
    #14 0x7ffff7a06f43 in __libc_start_main (/usr/lib/libc.so.6+0x25f43) (BuildId: 98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
    #15 0x5555555af1a4 in _start (/home/immanuel/Documents/mutable-org/mutable-db/build/DebugMSan/bin/run_tests+0x5b1a4) (BuildId: a83c5acd676678229971e14582b2369c6240f2cc
)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/immanuel/Documents/mutable-org/mutable-db/build/DebugMSan/src/catch2/internal/catch_reporter_registry.cpp:37:9 i
n Catch::ReporterRegistry::ReporterRegistry()
Exiting
@horenmar
Copy link
Member

horenmar commented Dec 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants