#1006 valgrind and dune-grid
Metadata
Property | Value |
---|---|
Reported by | Elias Pipping (elias.pipping@fu-berlin.de) |
Reported at | Dec 22, 2011 15:25 |
Type | Bug Report |
Version | Git (pre2.4) [autotools] |
Operating System | Linux |
Last edited by | Oliver Sander (oliver.sander@tu-dresden.de) |
Last edited at | Aug 3, 2012 10:30 |
Closed by | Oliver Sander (oliver.sander@tu-dresden.de) |
Closed at | Aug 3, 2012 10:30 |
Closed in version | Unknown |
Resolution | Works for me |
Comment | Please reopen if necessary |
Description
I find the following rather odd:
Imagine I have a piece of code like the following:
% < foo.cpp int main() { return 0; } %
Which I compile into foo.o:
% g++ -c foo.cpp
Linking it and running valgrind on the executable yields nothing surprising:
% g++ foo.o -o foo % valgrind ./foo ==4727== Memcheck, a memory error detector ==4727== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==4727== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info ==4727== Command: ./foo ==4727== ==4727== ==4727== HEAP SUMMARY: ==4727== in use at exit: 0 bytes in 0 blocks ==4727== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==4727== ==4727== All heap blocks were freed -- no leaks are possible ==4727== ==4727== For counts of detected and suppressed errors, rerun with: -v ==4727== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4) %
If I, however, link against the library dune-grid library as well:
% libtool --mode link g++ foo.o /dune-grid/build_clang/lib/libdunegrid.la -o foo libtool: link: g++ foo.o -o .libs/foo /dune-grid/build_clang/lib/.libs/libdunegrid.so %
Valgrind will tell me:
% libtool --mode execute valgrind ./foo ==5029== Memcheck, a memory error detector ==5029== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==5029== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info ==5029== Command: /.libs/lt-foo ==5029== ==5029== Invalid free() / delete / delete[] ==5029== at 0x4C240FD: free (vg_replace_malloc.c:366) ==5029== by 0x5DBB95A: free_mem (in /lib/libc-2.11.2.so) ==5029== by 0x5DBB4F1: __libc_freeres (in /lib/libc-2.11.2.so) ==5029== by 0x4A2067B: _vgnU_freeres (vg_preloaded.c:62) ==5029== by 0x5CE158D: __run_exit_handlers (exit.c:93) ==5029== by 0x5CE1634: exit (exit.c:100) ==5029== by 0x5CC9C53: (below main) (libc-start.c:260) ==5029== Address 0x4049008 is not stack'd, malloc'd or (recently) free'd ==5029== ==5029== ==5029== HEAP SUMMARY: ==5029== in use at exit: 0 bytes in 0 blocks ==5029== total heap usage: 48 allocs, 50 frees, 10,693 bytes allocated ==5029== ==5029== All heap blocks were freed -- no leaks are possible ==5029== ==5029== For counts of detected and suppressed errors, rerun with: -v ==5029== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 4 from 4) %
In the above output, I've manually replaced the path to foo.o with and the path to dune-grid with .