[llvm-bugs] [Bug 32387] New: string::size() use of uninitialized memory (MSan)
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 23 01:41:15 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32387
Bug ID: 32387
Summary: string::size() use of uninitialized memory (MSan)
Product: libc++
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: gonzalobg88 at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
The following MWE produces a MemorySanitizer error:
MWE:
#include <vector>
#include <string>
int main()
{
auto vec = std::vector<std::string>{{"a"}, {"b"}, {"c"}};
auto it = std::find(std::begin(vec), std::end(vec), "b");
assert(it2 == vec.begin() + 1);
}
Error:
==25671==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x49a8ca in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::size() const
/home/gonzalo/pool/msan/include/c++/v1/string:894:17
#1 0x49a8ca in bool std::__1::operator==<char, std::__1::char_traits<char>,
std::__1::allocator<char> >(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*)
/home/gonzalo/pool/msan/include/c++/v1/string:3581
#2 0x49a8ca in std::__1::__wrap_iter<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*>
std::__1::find<std::__1::__wrap_iter<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*>, char
[2]>(std::__1::__wrap_iter<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*>,
std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*>, char const (&) [2])
/home/gonzalo/pool/msan/include/c++/v1/algorithm:891
#3 0x49a8ca in main test.cpp:7
#4 0x7f220bb66b04 in __libc_start_main (/lib64/libc.so.6+0x21b04)
#5 0x42384e in _start
/home/abuild/rpmbuild/BUILD/glibc-2.19/csu/../sysdeps/x86_64/start.S:122
SUMMARY: MemorySanitizer: use-of-uninitialized-value
/home/gonzalo/pool/msan/include/c++/v1/string:894:17 in
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::size() const
Exiting
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170323/35985eeb/attachment.html>
More information about the llvm-bugs
mailing list