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.


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


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