Darryl Okahata <darrylo(a)soco.agilent.com> writes:
[ Now, if your program started writing to negative array indices,
valgrind would have a chance of detecting that, but I don't know if it
actually does. ]
If the corruption is on the stack, how could it know? For instance:
int
somfunc ()
{
int a, b, c;
char array[10];
char *foo, *bar, *baz;
... code that writes into array[-1], array[10], etc. ...
}
How can valgrind detect that the code is faulty if it writes into
otherwise valid regions of the stack? The code will silently corrupt
A, B, C and FOO, BAR, BAZ, and it will (I think) look
indistinguishable from the legitimate code that writes into their
memory.
(All variables allocated on the stack for the purpose of this
discussion.)