|
From: Igmar P. <mai...@jd...> - 2003-08-05 13:57:44
|
> > void f()
> > {
> > char a[4];
> > int *b;
> > int c;
> > b = &c;
> > a[5] = 123;
> > *b = 456;
> > }
> >
> > valgrind will tell you that the write through b is a problem,
> > but the real reason is the array overrun which valgrind cannot
> > detect, but which (indirectly) causes an array overrun.
>
> I just tried it, without problems, but that's probably due to GCC adding
> random padding between 'a' and 'b'.
GCC 3.x adds far more padding and alignment than 2.95.x does. No idea what
the reason is, but I observed that when debugging with code generated by
gcc -S
> You're right, I should have been more precise: if you get a seg fault due
> to an array overrun, Valgrind will always give you some related error
> message before the seg fault happens. Any objections to that statement? :)
I've seen a number of occasions when valgrind is totally of the track, all
of them with threaded apps screwing up each other stack. Gives nice
extremely hard to track problems :)
Igmar
|