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

Doctest spams several thousands warnings with memory sanitizer #721

Open
qarmin opened this issue Oct 26, 2022 · 1 comment
Open

Doctest spams several thousands warnings with memory sanitizer #721

qarmin opened this issue Oct 26, 2022 · 1 comment

Comments

@qarmin
Copy link

qarmin commented Oct 26, 2022

Description

When compliing doctest with memory sanitizer,

CXX=clang++ CXXFLAGS="-fsanitize=memory -fsanitize-recover=memory -fsanitize-memory-track-origins -Og" LDFLAGS="-fsanitize=memory" cmake .;make -j6

it produce thousands of warnings when executing examples/all_features/all_features

==110585==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55573e7a1bb9 in doctest::(anonymous namespace)::wildcmp(char const*, char const*, bool) main.cpp
    #1 0x55573e75fc7b in doctest::(anonymous namespace)::matchesAny(char const*, std::vector<doctest::String, std::allocator<doctest::String> > const&, bool, bool) main.cpp
    #2 0x55573e79270a in doctest::Context::run() (/home/rafal/test/doctest/examples/all_features/all_features+0x12770a) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #3 0x55573e79e5e8 in main (/home/rafal/test/doctest/examples/all_features/all_features+0x1335e8) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #4 0x7ffb3d635d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #5 0x7ffb3d635e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #6 0x55573e6c0704 in _start (/home/rafal/test/doctest/examples/all_features/all_features+0x55704) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)

  Uninitialized value was stored to memory at
    #0 0x55573e6ee709 in __msan_memcpy (/home/rafal/test/doctest/examples/all_features/all_features+0x83709) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #1 0x55573e74ea67 in doctest::String::String(doctest::String&&) (/home/rafal/test/doctest/examples/all_features/all_features+0xe3a67) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #2 0x55573e897194 in void __gnu_cxx::new_allocator<doctest::String>::construct<doctest::String, doctest::String>(doctest::String*, doctest::String&&) (/home/rafal/test/doctest/examples/all_features/all_features+0x22c194) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #3 0x55573e89576b in void std::allocator_traits<std::allocator<doctest::String> >::construct<doctest::String, doctest::String>(std::allocator<doctest::String>&, doctest::String*, doctest::String&&) (/home/rafal/test/doctest/examples/all_features/all_features+0x22a76b) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #4 0x55573e8963ad in void std::vector<doctest::String, std::allocator<doctest::String> >::_M_realloc_insert<doctest::String>(__gnu_cxx::__normal_iterator<doctest::String*, std::vector<doctest::String, std::allocator<doctest::String> > >, doctest::String&&) (/home/rafal/test/doctest/examples/all_features/all_features+0x22b3ad) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #5 0x55573e895435 in void std::vector<doctest::String, std::allocator<doctest::String> >::emplace_back<doctest::String>(doctest::String&&) (/home/rafal/test/doctest/examples/all_features/all_features+0x22a435) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #6 0x55573e817311 in std::vector<doctest::String, std::allocator<doctest::String> >::push_back(doctest::String&&) (/home/rafal/test/doctest/examples/all_features/all_features+0x1ac311) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #7 0x55573e7a2a51 in doctest::(anonymous namespace)::parseCommaSepArgs(int, char const* const*, char const*, std::vector<doctest::String, std::allocator<doctest::String> >&)::$_2::operator()() const main.cpp
    #8 0x55573e786aad in doctest::(anonymous namespace)::parseCommaSepArgs(int, char const* const*, char const*, std::vector<doctest::String, std::allocator<doctest::String> >&) main.cpp
    #9 0x55573e7786e1 in doctest::Context::parseArgs(int, char const* const*, bool) (/home/rafal/test/doctest/examples/all_features/all_features+0x10d6e1) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #10 0x55573e7896ca in doctest::Context::setOption(char const*, char const*) (/home/rafal/test/doctest/examples/all_features/all_features+0x11e6ca) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #11 0x55573e788e0c in doctest::Context::addFilter(char const*, char const*) (/home/rafal/test/doctest/examples/all_features/all_features+0x11de0c) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #12 0x55573e79e472 in main (/home/rafal/test/doctest/examples/all_features/all_features+0x133472) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #13 0x7ffb3d635d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

  Uninitialized value was stored to memory at
    #0 0x55573e6ee709 in __msan_memcpy (/home/rafal/test/doctest/examples/all_features/all_features+0x83709) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #1 0x55573e74c1e4 in doctest::String::String(char const*, unsigned int) (/home/rafal/test/doctest/examples/all_features/all_features+0xe11e4) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #2 0x55573e74bdd1 in doctest::String::String(char const*) (/home/rafal/test/doctest/examples/all_features/all_features+0xe0dd1) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #3 0x55573e7a2a11 in doctest::(anonymous namespace)::parseCommaSepArgs(int, char const* const*, char const*, std::vector<doctest::String, std::allocator<doctest::String> >&)::$_2::operator()() const main.cpp
    #4 0x55573e786aad in doctest::(anonymous namespace)::parseCommaSepArgs(int, char const* const*, char const*, std::vector<doctest::String, std::allocator<doctest::String> >&) main.cpp
    #5 0x55573e7786e1 in doctest::Context::parseArgs(int, char const* const*, bool) (/home/rafal/test/doctest/examples/all_features/all_features+0x10d6e1) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #6 0x55573e7896ca in doctest::Context::setOption(char const*, char const*) (/home/rafal/test/doctest/examples/all_features/all_features+0x11e6ca) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #7 0x55573e788e0c in doctest::Context::addFilter(char const*, char const*) (/home/rafal/test/doctest/examples/all_features/all_features+0x11de0c) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #8 0x55573e79e472 in main (/home/rafal/test/doctest/examples/all_features/all_features+0x133472) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #9 0x7ffb3d635d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

  Uninitialized value was stored to memory at
    #0 0x55573e6ee709 in __msan_memcpy (/home/rafal/test/doctest/examples/all_features/all_features+0x83709) (BuildId: 3ea1d43b0b3e71f1d4967436582f7754d57a2e19)
    #1 0x7ffb3da87ee4 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (/lib/x86_64-linux-gnu/libstdc++.so.6+0x14cee4) (BuildId: f57e02bfadacc0c923c82457d5e18e1830b5faea)

  Uninitialized value was created by an allocation of 's' in the stack frame of function '_ZN7doctest12_GLOBAL__N_117parseCommaSepArgsEiPKPKcS2_RSt6vectorINS_6StringESaIS6_EE'
    #0 0x55573e785720 in doctest::(anonymous namespace)::parseCommaSepArgs(int, char const* const*, char const*, std::vector<doctest::String, std::allocator<doctest::String> >&) main.cpp

SUMMARY: MemorySanitizer: use-of-uninitialized-value main.cpp in doctest::(anonymous namespace)::wildcmp(char const*, char const*, bool)

Extra information

  • doctest version: Git
  • Operating System: Ubuntu 22.04
  • Compiler+version: Clang 14
@onqtam
Copy link
Member

onqtam commented Oct 28, 2022

haven't looked in-depth, but could be because your STL is not built with MSAN - could be a duplicate issue like the previous reports for MSAN: https://github.com/doctest/doctest/issues?q=memory+sanitizer

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