Re: Valgrind - exact leak location.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Neil,

Thanks for your inputs.
Well by "exact location of error" I meant the line
number in my program file where the error occured.

As you can see

"ABCParser::parseString()(stl_vector.h:501)"

it says the error occured inside the function
parseString() but it doesn't indicate which line
number inside this function. the parseString()
function by itself runs to over 2000 lines(not written
by me).I know that the error is occuring when a
read/write is being performed beyond the boundary of
the vector variables used in the parseString()
function, but unfortunately because of its sheer size
I am unable to zero in on the exact location(line
number).

I tried inserting some print statements and zeroed in
on the invalid read but it is a pretty dumb approach,
I shall try using the debugger tip you gave me.

Thanks again
vatsan.

PS: thanks for pointing me to the valgrind mailing
list, I have already posted there, however I did not
get responses, so I thought of posting in the gcc
forum as I believed it had something to do with the
debugger flags associated with the gcc Makefiles.





--- Neil Ferguson <nferguso@xxxxxxx> wrote:

> 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.
> 


"MAN'S EGO IS THE FOUNTAINHEAD OF HUMAN PROGRESS"
                                          Ayn Rand.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux