When the path of the executable (built with gcc -g option) contains a (properly escaped) space character, the functions from that executable are not properly displayed in the stack trace. Instead ??? marks are printed as if the executable had no debug info. I don't know whether the same bug may be triggered by other characters in the path. HOW TO REPRODUCE: Create a file hello.cpp with the following contents: // file hello.cpp #include <iostream> #include <cstdlib> using namespace std; int main() { const char hello[] = "Hello, World"; char* msg = new char[8]; strcpy(msg, hello); cout << msg << endl; free(msg); return 0; } // end of file hello.cpp $ gcc -g -lstdc++ hello.cpp $ valgrind --tool=memcheck ./a.out ==16110== Memcheck, a memory error detector for x86-linux. ==16110== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al. ==16110== Using valgrind-2.2.0, a program supervision framework for x86-linux. ==16110== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al. ==16110== ==16110== My PID = 16110, parent PID = 15737. Prog and args are: ==16110== ./a.out ==16110== For more details, rerun with: -v ==16110== ==16110== Invalid write of size 1 ==16110== at 0x1B9036E8: strcpy (mac_replace_strmem.c:198) ==16110== by 0x80486EC: main (hello.cpp:10) ==16110== Address 0x1BB34030 is 0 bytes after a block of size 8 alloc'd ==16110== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16110== by 0x80486D7: main (hello.cpp:9) ==16110== ==16110== Invalid write of size 1 ==16110== at 0x1B9036F4: strcpy (mac_replace_strmem.c:199) ==16110== by 0x80486EC: main (hello.cpp:10) ==16110== Address 0x1BB34034 is 4 bytes after a block of size 8 alloc'd ==16110== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16110== by 0x80486D7: main (hello.cpp:9) ==16110== ==16110== Invalid read of size 1 ==16110== at 0x1B9036C5: strlen (mac_replace_strmem.c:189) ==16110== by 0x1B988F56: std::basic_ostream<char, std::char_traits<char> >& s td::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_trai ts<char> >&, char const*) (in /usr/lib/libstdc++.so.5.0.3) ==16110== by 0x8048707: main (hello.cpp:11) ==16110== Address 0x1BB34030 is 0 bytes after a block of size 8 alloc'd ==16110== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16110== by 0x80486D7: main (hello.cpp:9) ==16110== ==16110== Invalid read of size 1 ==16110== at 0x1B991EC5: std::basic_streambuf<char, std::char_traits<char> >: :xsputn(char const*, int) (in /usr/lib/libstdc++.so.5.0.3) ==16110== by 0x1B959447: std::basic_filebuf<char, std::char_traits<char> >::x sputn(char const*, int) (in /usr/lib/libstdc++.so.5.0.3) ==16110== by 0x1B9888D0: std::ostream::write(char const*, int) (in /usr/lib/l ibstdc++.so.5.0.3) ==16110== by 0x1B988FE5: std::basic_ostream<char, std::char_traits<char> >& s td::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_trai ts<char> >&, char const*) (in /usr/lib/libstdc++.so.5.0.3) ==16110== Address 0x1BB34030 is 0 bytes after a block of size 8 alloc'd ==16110== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16110== by 0x80486D7: main (hello.cpp:9) ==16110== ==16110== Mismatched free() / delete / delete [] ==16110== at 0x1B904281: free (vg_replace_malloc.c:153) ==16110== by 0x804871E: main (hello.cpp:12) ==16110== Address 0x1BB34028 is 0 bytes inside a block of size 8 alloc'd ==16110== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16110== by 0x80486D7: main (hello.cpp:9) ==16110== ==16110== ERROR SUMMARY: 15 errors from 5 contexts (suppressed: 17 from 1) ==16110== malloc/free: in use at exit: 0 bytes in 0 blocks. ==16110== malloc/free: 1 allocs, 1 frees, 8 bytes allocated. ==16110== For a detailed leak analysis, rerun with: --leak-check=yes ==16110== For counts of detected errors, rerun with: -v $ $ $ mv a.out a\ out $ valgrind --tool=memcheck ./a\ out ==16124== Memcheck, a memory error detector for x86-linux. ==16124== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al. ==16124== Using valgrind-2.2.0, a program supervision framework for x86-linux. ==16124== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al. ==16124== ==16124== My PID = 16124, parent PID = 15737. Prog and args are: ==16124== ./a out ==16124== For more details, rerun with: -v ==16124== ==16124== Invalid write of size 1 ==16124== at 0x1B9036E8: strcpy (mac_replace_strmem.c:198) ==16124== by 0x80486EC: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== Address 0x1BB34030 is 0 bytes after a block of size 8 alloc'd ==16124== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16124== by 0x80486D7: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== ==16124== Invalid write of size 1 ==16124== at 0x1B9036F4: strcpy (mac_replace_strmem.c:199) ==16124== by 0x80486EC: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== Address 0x1BB34034 is 4 bytes after a block of size 8 alloc'd ==16124== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16124== by 0x80486D7: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== ==16124== Invalid read of size 1 ==16124== at 0x1B9036C5: strlen (mac_replace_strmem.c:189) ==16124== by 0x1B988F56: std::basic_ostream<char, std::char_traits<char> >& s td::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_trai ts<char> >&, char const*) (in /usr/lib/libstdc++.so.5.0.3) ==16124== by 0x8048707: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== Address 0x1BB34030 is 0 bytes after a block of size 8 alloc'd ==16124== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16124== by 0x80486D7: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== ==16124== Invalid read of size 1 ==16124== at 0x1B991EC5: std::basic_streambuf<char, std::char_traits<char> >: :xsputn(char const*, int) (in /usr/lib/libstdc++.so.5.0.3) ==16124== by 0x1B959447: std::basic_filebuf<char, std::char_traits<char> >::x sputn(char const*, int) (in /usr/lib/libstdc++.so.5.0.3) ==16124== by 0x1B9888D0: std::ostream::write(char const*, int) (in /usr/lib/l ibstdc++.so.5.0.3) ==16124== by 0x1B988FE5: std::basic_ostream<char, std::char_traits<char> >& s td::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_trai ts<char> >&, char const*) (in /usr/lib/libstdc++.so.5.0.3) ==16124== Address 0x1BB34030 is 0 bytes after a block of size 8 alloc'd ==16124== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16124== by 0x80486D7: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== ==16124== Mismatched free() / delete / delete [] ==16124== at 0x1B904281: free (vg_replace_malloc.c:153) ==16124== by 0x804871E: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== Address 0x1BB34028 is 0 bytes inside a block of size 8 alloc'd ==16124== at 0x1B904112: operator new[](unsigned) (vg_replace_malloc.c:139) ==16124== by 0x80486D7: ??? ==16124== by 0x1B9E2747: __libc_start_main (in /lib/tls/libc-2.3.2.so) ==16124== by 0x804861C: ??? ==16124== ==16124== ERROR SUMMARY: 15 errors from 5 contexts (suppressed: 17 from 1) ==16124== malloc/free: in use at exit: 0 bytes in 0 blocks. ==16124== malloc/free: 1 allocs, 1 frees, 8 bytes allocated. ==16124== For a detailed leak analysis, rerun with: --leak-check=yes ==16124== For counts of detected errors, rerun with: -v WORKAROUND: Ensure that the path of the executable does not contain space characters.
The /proc/self/maps parser mis-parses lines containing ' ' in the filename. I haven't tried to repro this yet, but I can see that it might cause reporting problems.
I've fixed this in the 3.0 repository. It will probably fail on a filename containing a newline, but I'll worry about that case when someone complains.