Hi,
The following minimal program (only 7 lines) causes valgrind to report 2
errors, in line6:
Some somebody point me to why it is wrong?
a.cpp:
1 #include
2
3 int main( int, char** )
4 {
5 boost::filesystem::path path0( "/a/b/c" );
6 boost::filesystem::path path1 = path0.parent_path();
7 }
Compiling and running with valgrind:
g++ -g -lboost_system -lboost_filesystem a.cpp -o a.exe
valgrind ./a.exe
This gives the following output. Note the errors.
==13303== Memcheck, a memory error detector
==13303== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==13303== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==13303== Command: ./a.exe
==13303==
==13303== Invalid read of size 8
==13303== at 0x5B0A5C8: wcscmp (in /lib64/libc-2.18.so)
==13303== by 0x52CA5C4: std::moneypunct::~moneypunct() (in /usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52CA638: std::moneypunct::~moneypunct() (in /usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52C1304: std::locale::_Impl::~_Impl() (in
/usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52C143C: std::locale::~locale() (in
/usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x5AA775E: __cxa_finalize (in /lib64/libc-2.18.so)
==13303== by 0x503DD72: ??? (in /usr/lib64/libboost_filesystem.so.1.53.0)
==13303== by 0x400EE69: _dl_fini (in /lib64/ld-2.18.so)
==13303== by 0x5AA73D8: __run_exit_handlers (in /lib64/libc-2.18.so)
==13303== by 0x5AA7424: exit (in /lib64/libc-2.18.so)
==13303== by 0x5A90BEB: (below main) (in /lib64/libc-2.18.so)
==13303== Address 0x604c038 is 0 bytes after a block of size 8 alloc'd
==13303== at 0x4C284B7: operator new[](unsigned long) (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==13303== by 0x52CBC81: std::moneypunct::_M_initialize_moneypunct(__locale_struct*, char const*) (in
/usr/lib64/libstdc++.so.6
.0.18)
==13303== by 0x52C3807: std::locale::_Impl::_Impl(char const*,
unsigned long) (in /usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52C42D1: std::locale::locale(char const*) (in
/usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x50451B1: boost::filesystem::path::codecvt() (in
/usr/lib64/libboost_filesystem.so.1.53.0)
==13303== by 0x5046C7E: boost::filesystem::path::parent_path() const
(in /usr/lib64/libboost_filesystem.so.1.53.0)
==13303== by 0x401843: main (a.cpp:6)
==13303==
==13303== Invalid read of size 8
==13303== at 0x5B0A5C8: wcscmp (in /lib64/libc-2.18.so)
==13303== by 0x52CA4D4: std::moneypunct::~moneypunct()
(in /usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52CA548: std::moneypunct::~moneypunct()
(in /usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52C1304: std::locale::_Impl::~_Impl() (in
/usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52C143C: std::locale::~locale() (in
/usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x5AA775E: __cxa_finalize (in /lib64/libc-2.18.so)
==13303== by 0x503DD72: ??? (in /usr/lib64/libboost_filesystem.so.1.53.0)
==13303== by 0x400EE69: _dl_fini (in /lib64/ld-2.18.so)
==13303== by 0x5AA73D8: __run_exit_handlers (in /lib64/libc-2.18.so)
==13303== by 0x5AA7424: exit (in /lib64/libc-2.18.so)
==13303== by 0x5A90BEB: (below main) (in /lib64/libc-2.18.so)
==13303== Address 0x604c268 is 0 bytes after a block of size 8 alloc'd
==13303== at 0x4C284B7: operator new[](unsigned long) (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==13303== by 0x52CB6B1: std::moneypunct::_M_initialize_moneypunct(__locale_struct*, char const*) (in
/usr/lib64/libstdc++.so.6.
0.18)
==13303== by 0x52C3854: std::locale::_Impl::_Impl(char const*,
unsigned long) (in /usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x52C42D1: std::locale::locale(char const*) (in
/usr/lib64/libstdc++.so.6.0.18)
==13303== by 0x50451B1: boost::filesystem::path::codecvt() (in
/usr/lib64/libboost_filesystem.so.1.53.0)
==13303== by 0x5046C7E: boost::filesystem::path::parent_path() const
(in /usr/lib64/libboost_filesystem.so.1.53.0)
==13303== by 0x401843: main (a.cpp:6)
==13303==
==13303==
==13303== HEAP SUMMARY:
==13303== in use at exit: 0 bytes in 0 blocks
==13303== total heap usage: 483 allocs, 483 frees, 34,115 bytes allocated
==13303==
==13303== All heap blocks were freed -- no leaks are possible
==13303==
==13303== For counts of detected and suppressed errors, rerun with: -v
==13303== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)