It has been a while since I've used valgrind much, and have started trying
it again lately, but have a LOT of what I believe are bogus error reports
about uninitialized variables. Several I've traced back to obvious
initialization statements. I think the relevant point is that I'm running
on an x86_64 system, with 64 bit pointers and 32 bit data, but all the
"unitialized value" errors say "size 8"! But all my data is size 4!
I tried building a small example (the program I actually work on and use
valgrind for is approx 1.5M lines, mostly Fortran and some C), but of
course couldn't duplicate somthing quite so obviously wrong. I did get
this, which may or may not be helpful. This small program:
#include <stdio.h>
main()
{
int i,j;
for(i=j=0; i< 5; i++) {
j=do_sub(j);
}
printf("Result = %d\n",j);
}
int do_sub(int in)
{
int out;
//int junk=1; /* No errors */
int junk; /* Errors */
out = in+junk;
return out;
}
has an obvious error ("junk" is not initialized). When I build this on my
OpenSuSE 11.0 x86_64 system with the gcc 4.3.1 compiler, I either get no
valgrind errors (if junk=1 is used), or I get this (when junk is not
initialized):
==22349== Use of uninitialised value of size 8
==22349== at 0x4E6E423: (within /lib64/libc-2.8.so)
==22349== by 0x4E7166F: vfprintf (in /lib64/libc-2.8.so)
==22349== by 0x4E78FE9: printf (in /lib64/libc-2.8.so)
==22349== by 0x40055E: main (in /home/brian/tmp/tst)
Now, this "error" is in the system libraries, and I don't KNOW that the
error report is wrong. But I don't get ANY errors about the usage of junk,
or anything else. I've tried several arithmetic operations involving junk,
or out, or the results thereof, all with no errors reported.
In any case, in my real application, I get TONS of these "uninitialized
value" errors, and ALL say "size 8" -- even the ones that point to lines in
my code, where all the data is 32 bit data, and all the values HAVE been
initialized.
I suspect it is only looking at 8 byte chunks, and perhaps the 4 bytes I'm
using sit next to 4 bytes that are not initialized, and hence I get errors.
But I can't find any way to tell valgrind to do this check on 4 byte
intervals instead of 8.
Any suggestions?
(I just did this all with valgrind 3.3.1, and I've been seeing these kinds
of errors with 3.3.0, and some earlier versions. But I didn't have
problems before on 32 bit systems with earlier versions of valgrind...)
-- Brian
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users