Darryl Okahata <darrylo(a)soco.agilent.com> wrote:
Unfortunately, I don't think valgrind can detect the kind of
errors
that you had in your test program. I think the issue is that your
program was writing into "valid" areas of the stack (that is, an address
above $esp). To do what you want, valgrind would have to know what
parts of the stack belongs to data, and what parts of the stack belongs
to bookkeeping info (return addresses, saved registers, etc.), but
valgrind has no way of knowing that.
[ 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. ]
I was misled by:
http://developer.kde.org/~sewardj/docs-20031012/coregrind_intro.html
which says that it detects "reading/writing inappropriate areas on the
stack". Since valgrind simulates the CPU, I imagined that it might mark
the top of a new stack frame and catch accesses beyond that point. It
seemed plausible at the time. At any rate, it appears that valgrind is
not, in fact, doing this.
--
Jerry James, wondering what the definition of "inappropriate" is
http://www.ittc.ku.edu/~james/