public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kaz Kylheku" <kaz@zeugmasystems.com>
To: "Srivatsan Ramanujam" <juggernautvatsan@yahoo.com>,
		<gcc-help@gcc.gnu.org>
Subject: RE: Valgrind - exact leak location.
Date: Thu, 26 Oct 2006 16:06:00 -0000	[thread overview]
Message-ID: <66910A579C9312469A7DF9ADB54A8B7D418250@exchange.ZeugmaSystems.local> (raw)

> Hi People,
> 
> I have been trying to run valgrind to detect leaks in
> my backend C++ algorithm.

But what valgrind has detected is an invalid read, not a leak.

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

What leak? The routine is dereferencing an invalid pointer.

> Is there a way out? Can valgrind give me the exact
> line number in a file where the "invalid read"
> occured?

Let's look at it:

==9984==    by 0x1B97AB4E: ABCParser::parseString() (stl_vector.h:501)

The invalid read did occur in stl_vector.h:501. But that is the middle
of an inlined function that was incorporated into the body of
parseString(). It doesn't have its own stack frame, which would give a
backtrace to the parent function.

Inlining is an optimization which, as you can see, can interfere with
debugging.

Have you thought of recompiling the code with inlining disabled?

> How can I make valgrind point out the exact location
> of the error in my code?

In what way is is the machine address 0x1B97AB4E  not an exact location?

Compile with -g, and then use objdump -S to an assembly listing
annotated with the source code lines.

             reply	other threads:[~2006-10-26 16:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26 16:06 Kaz Kylheku [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-10-26  6:32 Srivatsan Ramanujam
2006-10-26 10:04 ` Andrew Haley
2006-10-26 11:44   ` William Gallafent
2006-10-26 11:57   ` Neil Ferguson
2006-10-26 12:10     ` Srivatsan Ramanujam
2006-10-26 12:25       ` Andrew Haley
2006-10-26 12:32         ` Srivatsan Ramanujam
2006-10-26 12:34           ` Andrew Haley
2006-10-26 12:37             ` Srivatsan Ramanujam
2006-10-26 12:38           ` John Love-Jensen
2006-10-26 12:40             ` Srivatsan Ramanujam
2006-10-26 12:14   ` Srivatsan Ramanujam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=66910A579C9312469A7DF9ADB54A8B7D418250@exchange.ZeugmaSystems.local \
    --to=kaz@zeugmasystems.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=juggernautvatsan@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).