Re: Valgrind - used gdb

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

 



Hi all,

I used db--detach option to invoke the debugger from
valgrind when the invalid read occurred, here is what
i got.

----------------------------------
Program received signal SIGSTOP, Stopped (signal).
ABCParser::parseString (this=0x344b86f0) at
stl_vector.h:501
501           operator[](size_type __n) { return
*(begin() + __n); }
----------------------------------

thats where the invalid read occurred.

Now i used backtrace to get where it was invoked.


----------------------------------
gdb) backtrace
#0  ABCParser::parseString (this=0x344b86f0) at
stl_vector.h:501
#1  0x341bb8f3 in ABCParser::execute (this=0x344b86f0)
at ABCParser.cpp:97
#2  0x080499aa in main (argc=2, argv=0x9c5fdc64) at
testAlgo.cpp:31

----------------------------------
it again says that the error occured in the function.
parseString() (but no line number is shown :-( )

I tried looking into what stl_vector.h is doing at the
specified lines using the list command...and here is
what i got.

-----------------------------------
ABCParser::parseString (this=0x344b86f0) at
stl_vector.h:501
501           operator[](size_type __n) { return
*(begin() + __n); }
(gdb) list
496            *  Note that data access with this
operator is unchecked and
497            *  out_of_range lookups are not
defined. (For checked lookups
498            *  see at().)
499            */
500           reference
501           operator[](size_type __n) { return
*(begin() + __n); }
502
503           /**
504            *  @brief  Subscript access to the data
contained in the %vector.
505            *  @param n The index of the element
for which data should be
(gdb)
-----------------------------------------------------

it doesn't seem to say anything more....i know that
the invalid read is cause when a vector variable is
read beyond its boundary....but which one?? there are
so many vectors in my prog...and it is a one huge
function.

please shed some light.

thanks
vatsan




--- John Love-Jensen <eljay@xxxxxxxxx> wrote:

> Hi Srivatsan,
> 
> > Isn't line 501 inside stl_vector.h?
> 
> Yes.
> 
> If you want, break into the debugger (gdb) and do a
> backtrace to see where
> up the stack which frame and what line your routine
> was at.
> 
> Make sure you compile your code with -g.
> 
> --Eljay
> 
> 


"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