|
From: Nicholas N. <nj...@ca...> - 2004-01-17 14:02:32
|
On Wed, 14 Jan 2004, S=E9bastien de Menten wrote:
> #define N 16
> main()
> {
> int a[N];
> // int *a =3D new int[N];
> int i;
> for(i=3D0; i<=3DN+10; i++)
> a[i] =3D 0;
> return (0);
> }
>
> The error message is cryptic:
> =3D=3D5749=3D=3D Jump to the invalid address stated on the next line
> =3D=3D5749=3D=3D at 0x0: ???
> =3D=3D5749=3D=3D Address 0x0 is not stack'd, malloc'd or free'd
>
> If I change the line
> for(i=3D0; i<=3DN+10; i++)
> by
> for(i=3D0; i<=3DN; i++)
> it does not detect the error.
>
> If I allocate the memory dynamically,i.e.
> // int a[N];
> int *a =3D new int[N];
> Valgrind detects correctly the error.
>
> Does it mean that valgrind is unable to check the stack allocated memory =
?
That's right. The cryptic error message is occurring because the array
overrun would be clobbering the return address on the stack, so when the
function returns it tries to jump to 0x0.
N
|