From: Yeshurun, M. <mei...@in...> - 2005-10-17 21:06:33
|
The purpose of this little program was to do exactly that. My question is why isn't the error suppressed by specifying = --partial-loads-ok=3Dyes. Meir -----Original Message----- From: Brian Crowder [mailto:cr...@fi...]=20 Sent: Monday, October 17, 2005 11:03 PM To: Yeshurun, Meir Cc: Tom Hughes; val...@li... Subject: Re: [Valgrind-users] User error? - Valgrind 3 failing terribly compared to purify "XXX" is uninitialized memory. Ints are assumed to be 4-byte: a =3D { '0', '1', '2', '3', '4', '5', 6', '7', '8', '9', = 0, XXX, XXX } ((int*)a + 9) =3D { ............................................RRR, = RRR, RRR, RRR } the last two bytes being read in the int dereference are uninitialized memory. -- Brian Yeshurun, Meir wrote: > The following program generates an invalid read even when explicitly > specifying --partial-loads-ok=3Dyes. Am I missing something here? >=20 > #include <cstring> > #include <iostream> >=20 > using namespace std; >=20 > int main() > { > char *a =3D new char[11]; > strcpy(a, "0123456789"); > int b =3D *(int *)(a + 9); =20 > } >=20 >=20 > Thanks, >=20 > Meir >=20 > -----Original Message----- > From: val...@li... > [mailto:val...@li...] On Behalf Of Tom > Hughes > Sent: Monday, October 17, 2005 9:07 PM > To: val...@li... > Subject: RE: [Valgrind-users] User error? - Valgrind 3 failing terribly > compared to purify >=20 > In message > <942...@ha...> > "Yeshurun, Meir" <mei...@in...> wrote: >=20 >=20 >>There is one issue though: It looks like Valgrind reports partial >=20 > loads >=20 >>as errors by default. I think this shouldn't be the default behavior. >=20 >=20 > Actually valgrind doesn't report any loads as errors - it only > reports an error when you use an undefined value in a way that > would effect the result of the program. In other words when a > conditional jump depends on it or you use it as a pointer and > read or write through that pointer. >=20 > It tracks definedness at bit level, so a partial load will mark > some bits as defined and leaves others alone. If you then later > use one of the undefined bits it will complain. >=20 > There are edge cases where it thinks a bit is used when it isn't > really but they are rare. >=20 > I think you need to explain what you mean more fully. >=20 > Tom >=20 |