This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Valgrind - exact leak location.


Not a GCC question, but I'll have a pot at it anyway.

For future reference, the right place to ask this sort of question is the valgrind-users mailing list - see here:

http://www.valgrind.org/support/mailing_lists.html

> ==9984== by 0x1B97AB4E: ABCParser::parseString()
> (stl_vector.h:501)
> ==9984== by 0x1B975D34: ABCParser::execute()
> (ABCParser.cpp:101)
> ==9984== by 0x80499A9: main (testAlgo.cpp:31)
> ==9984== Address 0x7 is not stack'd, malloc'd or
> (recently) free'd
> ----------------------------------------------------
> > the rogue operation is being performed inside
> ABCParser::parseString() however this is a very big
> function and I am unable to painstakingly go thru it
> to find out the possible source of leak.
> > Is there a way out? Can valgrind give me the exact
> line number in a file where the "invalid read"
> occured?

Valgrind *has* given you the line number, but the error happens to show up inside a piece of inlined code from stl_vector.h. There are two ways to handle this:


1. Get Valgrind to start a debugger for you when the error happens - run 'valgrind --help', then look for the '--db-attach' & '--db-command' options.

2. The fact that this happens in inlined vector code means that your method must have been performing a vector operation at the time. You may find that narrows things down enough to skim ABCParser::parseString() more quickly. If you look at the area around line 501 in stl_vector.h, you may be able to find out which vector operation was being called, narrowing things down still further.

Hope that helps!

Neil.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]