Issue 88 in memory-sanitizer: msan false positive when using std::{cout|cerr|clog}.

31 views
Skip to first unread message

memory-s...@googlecode.com

unread,
Mar 26, 2015, 6:48:38 AM3/26/15
to memory-s...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 88 by ygors...@chromium.org: msan false positive when using
std::{cout|cerr|clog}.
https://code.google.com/p/memory-sanitizer/issues/detail?id=88

What steps will reproduce the problem?
1. Compile with msan and libc++ instrumented by msan following code:
#include <iostream>

int main() {
const char foo[] = "foo";
std::cout << foo << std::endl;
return 0;
}

2. Run it.

What is the expected output?
"foo" in the stdout.

What do you see instead?
==10290== WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f85c31a9a92 in std::__1::basic_ostream<char,
std::__1::char_traits<char> >& std::__1::__put_character_sequence<char,
std::__1::char_traits<char> >(std::__1::basic_ostream<char,
std::__1::char_traits<char> >&, char const*, unsigned long)
/home/y/coding/llvm/libcxx-msan/include/c++/v1/ostream:752:13
#1 0x7f85c31a7bbf in std::__1::basic_ostream<char,
std::__1::char_traits<char> >& std::__1::operator<<
<std::__1::char_traits<char> >(std::__1::basic_ostream<char,
std::__1::char_traits<char> >&, char const*)
/home/y/coding/llvm/libcxx-msan/include/c++/v1/ostream:894:12
#2 0x7f85c31a7792 in main /home/y/coding/msan-tests/main.cc:5:13
#3 0x7f85c1a46ec4 in __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:287
#4 0x7f85c31408ee in _start (/home/y/coding/msan-tests/bin/main+0x198ee)

Uninitialized value was created by an allocation of '__s' in the stack
frame of
function '_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m'
#0 0x7f85c31a8880 in std::__1::basic_ostream<char,
std::__1::char_traits<char> >& std::__1::__put_character_sequence<char,
std::__1::char_traits<char> >(std::__1::basic_ostream<char,
std::__1::char_traits<char> >&, char const*, unsigned long)
/home/y/coding/llvm/libcxx-msan/include/c++/v1/ostream:746

SUMMARY: MemorySanitizer: use-of-uninitialized-value
/home/y/coding/llvm/libcxx-msan/include/c++/v1/ostream:752:13 in
std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::__put_character_sequence<char, std::__1::char_traits<char>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char
const*, unsigned long)
Exiting

What version of the product are you using?
I'm using custom llvm(r233049) and clang(r233053) build, also, I'm linking
with msan-instrumented libc++ (r233012). I attached CMakeLists.txt which
contains options I use and main.cc files.


Attachments:
CMakeLists.txt 679 bytes
main.cc 109 bytes

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

memory-s...@googlecode.com

unread,
Mar 26, 2015, 7:35:14 AM3/26/15
to memory-s...@googlegroups.com

Comment #1 on issue 88 by ygors...@chromium.org: msan false positive when
What's interesting, after replacement of cout to printf() everything works
fine.

memory-s...@googlecode.com

unread,
Mar 26, 2015, 12:15:48 PM3/26/15
to memory-s...@googlegroups.com

Comment #2 on issue 88 by konstant...@gmail.com: msan false positive when
Welcome back! :)
What happens if you try this step-by-step?
https://code.google.com/p/memory-sanitizer/wiki/LibcxxHowTo

memory-s...@googlecode.com

unread,
Mar 26, 2015, 2:02:39 PM3/26/15
to memory-s...@googlegroups.com

Comment #3 on issue 88 by euge...@google.com: msan false positive when
This is exactly what I see when running with _uninstrumented_ libc++.
With _instrumented_ libc++ the test passes.
Please verify that the right library is used at runtime (with -Wl,-rpath or
LD_LIBRARY_PATH, see the link in #2).

memory-s...@googlecode.com

unread,
Mar 27, 2015, 5:52:55 AM3/27/15
to memory-s...@googlegroups.com

Comment #4 on issue 88 by ygors...@chromium.org: msan false positive when
Thank you, eugenis@! It seems that I've used uninstrumented libc++ - after
rebuilding everything works fine!

memory-s...@googlecode.com

unread,
Mar 27, 2015, 10:32:44 AM3/27/15
to memory-s...@googlegroups.com
Updates:
Status: Invalid

Comment #5 on issue 88 by euge...@google.com: msan false positive when
(No comment was entered for this change.)
Reply all
Reply to author
Forward
0 new messages