Created
May 30, 2016 17:47
-
-
Save shurane/9dfd8979934064bf9324e21e9bf38913 to your computer and use it in GitHub Desktop.
valgrind uninitialized values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ clang++ -Wall --std=c++11 uninitialized.cpp -o main | |
$ valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./main | |
==17245== Memcheck, a memory error detector | |
==17245== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. | |
==17245== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info | |
==17245== Command: ./main | |
==17245== | |
==17245== Conditional jump or move depends on uninitialised value(s) | |
==17245== at 0x4EBFCDE: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4EC02BC: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4ECC06D: std::ostream& std::ostream::_M_insert<long>(long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x400857: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== Uninitialised value was created by a heap allocation | |
==17245== at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) | |
==17245== by 0x400827: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== | |
==17245== Use of uninitialised value of size 8 | |
==17245== at 0x4EBFBC3: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4EBFD05: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4EC02BC: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4ECC06D: std::ostream& std::ostream::_M_insert<long>(long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x400857: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== Uninitialised value was created by a heap allocation | |
==17245== at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) | |
==17245== by 0x400827: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== | |
==17245== Conditional jump or move depends on uninitialised value(s) | |
==17245== at 0x4EBFBCF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4EBFD05: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4EC02BC: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4ECC06D: std::ostream& std::ostream::_M_insert<long>(long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x400857: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== Uninitialised value was created by a heap allocation | |
==17245== at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) | |
==17245== by 0x400827: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== | |
==17245== Conditional jump or move depends on uninitialised value(s) | |
==17245== at 0x4EBFD33: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4EC02BC: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x4ECC06D: std::ostream& std::ostream::_M_insert<long>(long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19) | |
==17245== by 0x400857: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== Uninitialised value was created by a heap allocation | |
==17245== at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) | |
==17245== by 0x400827: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== | |
0000000000000000000000000000000000000000000000000000000000000000==17245== | |
==17245== HEAP SUMMARY: | |
==17245== in use at exit: 256 bytes in 1 blocks | |
==17245== total heap usage: 1 allocs, 0 frees, 256 bytes allocated | |
==17245== | |
==17245== 256 bytes in 1 blocks are definitely lost in loss record 1 of 1 | |
==17245== at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) | |
==17245== by 0x400827: main (in /home/ehtesh/tmp/stl-rewrite-2/main) | |
==17245== | |
==17245== LEAK SUMMARY: | |
==17245== definitely lost: 256 bytes in 1 blocks | |
==17245== indirectly lost: 0 bytes in 0 blocks | |
==17245== possibly lost: 0 bytes in 0 blocks | |
==17245== still reachable: 0 bytes in 0 blocks | |
==17245== suppressed: 0 bytes in 0 blocks | |
==17245== | |
==17245== For counts of detected and suppressed errors, rerun with: -v | |
==17245== ERROR SUMMARY: 257 errors from 5 contexts (suppressed: 0 from 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main(int argc, char** argv){ | |
int *s = new int[64]; | |
for (auto i=0; i<64; i++){ | |
std::cout << s[i]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment