|
From: Christopher T. <Chr...@pa...> - 2005-10-18 00:41:48
|
This has been talked around already, but i wanted to be very clear: the =
example program given here is fundamentally incorrect. It is perfectly =
valid for a conforming compiler to emit code that causes this program to =
segfault on the access to *(int*)(a+9).
(This is done explicitly sometimes in debug allocators -- the requested =
block is located at the end of a VM page, and the following page is =
marked unreadable/unwritable.)
--
Christopher Tate
chr...@pa...
> -----Original Message-----
> From: val...@li...
> [mailto:val...@li...]On Behalf Of
> Yeshurun, Meir
> Sent: Monday, October 17, 2005 1:55 PM
> To: Tom Hughes
> Cc: val...@li...
> Subject: RE: [Valgrind-users] User error? - Valgrind 3=20
> failing terribly
> compared to purify
>=20
>=20
> 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=20
> failing terribly
> compared to purify
>=20
> In message
> <942...@ha...rp.i
> ntel.com>
> "Yeshurun, Meir" <mei...@in...> wrote:
>=20
> > There is one issue though: It looks like Valgrind reports partial
> loads
> > as errors by default. I think this shouldn't be the default=20
> behavior.
>=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
> --=20
> Tom Hughes (to...@co...)
> http://www.compton.nu/
>=20
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Valgrind-users mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>=20
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,=20
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Valgrind-users mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>=20
|