#33745: Valgrind fails to show file/line of leak/error -----------------------------------+---------------------------------------- Reporter: clint.olsen@… | Owner: raimue@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.0.4 Keywords: | Port: valgrind -----------------------------------+---------------------------------------- Changes (by cal@…): * keywords: valgrind, g++ => * owner: macports-tickets@… => raimue@… * cc: cal@… (added) Old description:
I have a small piece of C++ software that demonstrates leaks, but for whatever reason I cannot coax the file and line numbers. I used /usr/bin/g++ -g -W -Wall to compile every source. Some sources were generated by flex and bison, but otherwise it's just straightforward C++.
==985== 96 bytes in 4 blocks are definitely lost in loss record 13 of 22 ==985== at 0xB823: malloc (vg_replace_malloc.c:266) ==985== by 0x5768D: operator new(unsigned long) (in /usr/lib/libstdc++.6.0.9.dylib) ==985== by 0x100003BB5: yylex(YYSTYPE*, void*) (in ./re) ==985== by 0x1000016C7: yyparse(Parser*, void*) (in ./re) ==985== by 0x10000291C: main (in ./re)
I attempted to reproduce with the following piece of C++ code, but it works. So, there's some difference between the two cases:
$ cat leak.cpp class Foo { const char *name; int age;
public:
Foo(const char *name_, int age_) : name(name_), age(age_) {};
};
int main(int argc, char *argv[]) {
Foo *foo = new Foo("foo", 1);
foo = new Foo("bar", 2);
return 0; } $ g++ -W -Wall -g -o leak leak.cpp leak.cpp:11: warning: unused parameter ‘argc’ leak.cpp:11: warning: unused parameter ‘argv’
$ valgrind --leak-check=full ./leak ==1299== Memcheck, a memory error detector ==1299== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==1299== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==1299== Command: ./leak ==1299== ==1299== ==1299== HEAP SUMMARY: ==1299== in use at exit: 2,229 bytes in 34 blocks ==1299== total heap usage: 34 allocs, 0 frees, 2,229 bytes allocated ==1299== ==1299== 16 bytes in 1 blocks are definitely lost in loss record 2 of 10 ==1299== at 0xB823: malloc (vg_replace_malloc.c:266) ==1299== by 0x5768D: operator new(unsigned long) (in /usr/lib/libstdc++.6.0.9.dylib) ==1299== by 0x100000E56: main (leak.cpp:14) ...
Any suggestions you may have would be much appreciated.
New description: I have a small piece of C++ software that demonstrates leaks, but for whatever reason I cannot coax the file and line numbers. I used /usr/bin/g++ -g -W -Wall to compile every source. Some sources were generated by flex and bison, but otherwise it's just straightforward C++. {{{ ==985== 96 bytes in 4 blocks are definitely lost in loss record 13 of 22 ==985== at 0xB823: malloc (vg_replace_malloc.c:266) ==985== by 0x5768D: operator new(unsigned long) (in /usr/lib/libstdc++.6.0.9.dylib) ==985== by 0x100003BB5: yylex(YYSTYPE*, void*) (in ./re) ==985== by 0x1000016C7: yyparse(Parser*, void*) (in ./re) ==985== by 0x10000291C: main (in ./re) }}} I attempted to reproduce with the following piece of C++ code, but it works. So, there's some difference between the two cases: {{{ $ cat leak.cpp class Foo { const char *name; int age; public: Foo(const char *name_, int age_) : name(name_), age(age_) {}; }; int main(int argc, char *argv[]) { Foo *foo = new Foo("foo", 1); foo = new Foo("bar", 2); return 0; } $ g++ -W -Wall -g -o leak leak.cpp leak.cpp:11: warning: unused parameter ‘argc’ leak.cpp:11: warning: unused parameter ‘argv’ $ valgrind --leak-check=full ./leak ==1299== Memcheck, a memory error detector ==1299== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==1299== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==1299== Command: ./leak ==1299== ==1299== ==1299== HEAP SUMMARY: ==1299== in use at exit: 2,229 bytes in 34 blocks ==1299== total heap usage: 34 allocs, 0 frees, 2,229 bytes allocated ==1299== ==1299== 16 bytes in 1 blocks are definitely lost in loss record 2 of 10 ==1299== at 0xB823: malloc (vg_replace_malloc.c:266) ==1299== by 0x5768D: operator new(unsigned long) (in /usr/lib/libstdc++.6.0.9.dylib) ==1299== by 0x100000E56: main (leak.cpp:14) ... }}} Any suggestions you may have would be much appreciated. -- Comment: Please use WikiFormatting and remember to Cc the maintainer. Is there a `re.dSYM` directory next to the `re` binary? Does dwarfdump `re.dSYM` list the source code and debug symbols? -- Ticket URL: <https://trac.macports.org/ticket/33745#comment:1> MacPorts <http://www.macports.org/> Ports system for Mac OS