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

MemorySanitizer: use-of-uninitialized-value #731

Closed
springmeyer opened this issue Oct 19, 2016 · 5 comments
Closed

MemorySanitizer: use-of-uninitialized-value #731

springmeyer opened this issue Oct 19, 2016 · 5 comments
Labels

Comments

@springmeyer
Copy link

Seeing this with clang 3.9 on linux and a program built against catch with -fsanitize=memory:

==16495==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x51cd11 in std::_Rb_tree<std::string, std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> >, std::_Select1st<std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> > >, std::less<std::string>, std::allocator<std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> > > >::_M_get_insert_unique_pos(std::string const&) /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:1442:7
    #1 0x51c7f3 in std::pair<std::_Rb_tree_iterator<std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> > >, bool> std::_Rb_tree<std::string, std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> >, std::_Select1st<std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> > >, std::less<std::string>, std::allocator<std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> > > >::_M_insert_unique<std::pair<std::string, Catch::Ptr<Catch::IReporterFactory> > >(std::pair<std::string, Catch::Ptr<Catch::IReporterFactory> >&&) /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:1498:4
    #2 0x51c4ea in std::pair<std::_Rb_tree_iterator<std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> > >, bool> std::map<std::string, Catch::Ptr<Catch::IReporterFactory>, std::less<std::string>, std::allocator<std::pair<std::string const, Catch::Ptr<Catch::IReporterFactory> > > >::insert<std::pair<std::string, Catch::Ptr<Catch::IReporterFactory> >, void>(std::pair<std::string, Catch::Ptr<Catch::IReporterFactory> >&&) /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_map.h:638:23
    #3 0x51c348 in Catch::ReporterRegistry::registerReporter(std::string const&, Catch::Ptr<Catch::IReporterFactory> const&) /home/travis/build/mapbox/wagyu/./tests/catch.hpp:6666:25
    #4 0x4b39cb in Catch::(anonymous namespace)::RegistryHub::registerReporter(std::string const&, Catch::Ptr<Catch::IReporterFactory> const&) /home/travis/build/mapbox/wagyu/./tests/catch.hpp:6771:36
    #5 0x4c6910 in Catch::ReporterRegistrar<Catch::JunitReporter>::ReporterRegistrar(std::string const&) /home/travis/build/mapbox/wagyu/./tests/catch.hpp:8881:37
    #6 0x41e96e in __cxx_global_var_init.67 /home/travis/build/mapbox/wagyu/./tests/catch.hpp:9547:5
    #7 0x41edfc in _GLOBAL__sub_I_test.cpp /home/travis/build/mapbox/wagyu/./tests/test.cpp
    #8 0x763a9c in __libc_csu_init (/home/travis/build/mapbox/wagyu/test+0x763a9c)
    #9 0x7faee215377f  (/lib/x86_64-linux-gnu/libc.so.6+0x2177f)
    #10 0x420a98 in _start (/home/travis/build/mapbox/wagyu/test+0x420a98)
@springmeyer
Copy link
Author

If anyone has ideas on how to fix this I would love to hear them. It is very hard to suppress errors from MSan unless you build your own standard library with Msan (https://llvm.org/bugs/show_bug.cgi?id=30740), so fixing this in catch.hpp would be ideal.

@horenmar
Copy link
Member

This is most likely a false positive caused by uninstrumented libstdc++/libc++.

If there is something Catch can do to workaround it, we would be willing to implement it, but it is fairly unlikely.

@horenmar horenmar added the Resolved - pending review Issue waiting for feedback from the original author label Feb 28, 2017
@horenmar
Copy link
Member

We could potentially try messing around with __msan_unpoison, but it would be very, very, very low on the priority list. I am going to close this iseue and tag it with revisit.

@horenmar horenmar added Revisit and removed Resolved - pending review Issue waiting for feedback from the original author labels Mar 18, 2017
aarongable pushed a commit to chromium/chromium that referenced this issue Feb 14, 2019
Changes:
Msan test crash occur when ChromeVox is enabled and expand arrow button
hitting animation is running. The crash may be caused by false positive
from Memory sanitizer (catchorg/Catch2#731).
To avoid such crash and unblock adding more ChromeVox tests, disable the
animation for app list during test.

Bug: 926038
Change-Id: I5c775388cb96443ffe4462c870dd023609d3ddb8
Reviewed-on: https://chromium-review.googlesource.com/c/1471499
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632287}
@hsaturn
Copy link

hsaturn commented Jan 29, 2023

I have the same problem but I do use -stdlib=libc++

    linux-vdso.so.1 (0x00007ffefc74f000)
    libc++.so.1 => /lib/x86_64-linux-gnu/libc++.so.1 (0x00007ff9cc22f000)
    libunwind.so.1 => /lib/x86_64-linux-gnu/libunwind.so.1 (0x00007ff9cc224000)
    libc++abi.so.1 => /lib/x86_64-linux-gnu/libc++abi.so.1 (0x00007ff9cc1ee000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff9cc107000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff9cc0e7000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff9cbebf000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff9cde54000)

Could anyone explain how to get rid of the error ??? I saw some bug reports, closed, but never how to fix this ?
I think but am not sure that this is related to how libc++ was compiled.... maybe...
It would be kind if instead of just closing or linking to duplicates (that do not show ore explain more) one could take time to simply guide us.

  • What options to pass to clang (-fsanitize=memory -fsanitize-recover=memory for me)
  • What options to compiler (only -stdlib=libc++ for me)
  • What are the prerequisite on libc++ compiling (I'm under ubuntu and used apt install libc++-14-dev libc++abi-dev

I give up after hours, maybe I ws unlucky in my searches but I have to go forward. So now vim will delete for me paragraphs that are poisonning me (g/something/norm dap)

Best regards

@horenmar
Copy link
Member

horenmar commented Feb 1, 2023

You need to recompile your stdlib with -fsanitize=memory enabled, and then link against that recompiled stdlib.

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

No branches or pull requests

3 participants