|
From: Andreas A. <and...@da...> - 2005-01-18 16:49:15
|
Hi I have been using valgrind to debug a program I have written in C++ and it has been very helpful in eliminating memory errors/leaks. However, I just recently discovered a bug and from what I can see it looks like some kind of memory problem. However, when I run it through valgrind no errors are reported and the bug seems to be gone! I print some status from the program and at some point this becomes wrong but when the program is run through valgrind the status printed is right! How can valgrind change the output of my program and does this behaviour give any clues as to what kind of bug I am looking for? /Andreas |
|
From: David E. <tw...@us...> - 2005-01-18 18:02:31
|
On Tue, 2005-01-18 at 17:48 +0100, Andreas Andersen wrote:
> Hi
>
> I have been using valgrind to debug a program I have written in C++ and
> it has been very helpful in eliminating memory errors/leaks. However, I
> just recently discovered a bug and from what I can see it looks like
> some kind of memory problem. However, when I run it through valgrind no
> errors are reported and the bug seems to be gone! I print some status
> from the program and at some point this becomes wrong but when the
> program is run through valgrind the status printed is right!
>
> How can valgrind change the output of my program and does this behaviour
> give any clues as to what kind of bug I am looking for?
Stack corruption.
--
Regards,
-\- David Eriksson -/-
SynCE - http://synce.sourceforge.net
ScummVM - http://scummvm.sourceforge.net
Desquirr - http://desquirr.sourceforge.net
|
|
From: Chris S. <c.s...@co...> - 2005-01-18 22:13:50
|
On Tue, Jan 18, 2005 at 05:48:52PM +0100, Andreas Andersen wrote: > Hi > > I have been using valgrind to debug a program I have written in C++ and > it has been very helpful in eliminating memory errors/leaks. However, I > just recently discovered a bug and from what I can see it looks like > some kind of memory problem. However, when I run it through valgrind no > errors are reported and the bug seems to be gone! I print some status > from the program and at some point this becomes wrong but when the > program is run through valgrind the status printed is right! > > How can valgrind change the output of my program and does this behaviour > give any clues as to what kind of bug I am looking for? > Well, I've noticed that valgrind can continue through a double-free bug, when the program would crash without valgrind. But valgrind reports the error, so that's probably not your case. -chris |
|
From: Paul P. <ppl...@gm...> - 2005-01-19 00:43:56
|
On Tue, 18 Jan 2005 17:48:52 +0100, Andreas Andersen <and...@da...> wrote: > I just recently discovered a bug and from what I can see it looks like > some kind of memory problem. However, when I run it through valgrind no > errors are reported and the bug seems to be gone! There are a couple of likely explanations. If your program is multi-threaded; it is quite likely that VG changes timing or simply hides the race condition that caused corruption (your executable runs on a *single* synthetic CPU, so a whole class of SMP races "hides" under VG). If your program uses signal handlers, and especially if it calls malloc() from within async signal handler, VG might mask this. It appears that VG2.2 does not report such errors. It could be that your program uses uninitialized value, and you've either suppressed or ignored it in VG output. Finally, it could be that your program corrupts its state through a pointer that happens to point into something valid but un-important iwhen under VG, and something important when not under VG (the memory layout of the process changes under VG). Cheers, |