|
From: Anders T. <to...@lu...> - 2004-06-22 06:42:42
|
If I understand things correctly, Valgrind cannot detect this type of
problem (at least it did not when I tested it):
int
main(void)
{
int a[2];
a[2] = 1;
return 0;
}
Are there any plans for being able to detect stack problems, or is there
a workaround today (a compile flag to gcc perhaps)?
I'm not an expert on this, but I suppose that the binary need to be
rebuilt as purify does (inserting boundary space between the variables)
in order to support checking on the stack, and therefore we will not
see any support for this in Valgrind?
/Anders Torger
|
|
From: Tom H. <th...@cy...> - 2004-06-22 07:31:12
|
In message <200...@lu...>
Anders Torger <to...@lu...> wrote:
> I'm not an expert on this, but I suppose that the binary need to be
> rebuilt as purify does (inserting boundary space between the variables)
> in order to support checking on the stack, and therefore we will not
> see any support for this in Valgrind?
That's pretty much the current situation, yes.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|
|
From: Nicholas N. <nj...@ca...> - 2004-06-22 08:45:57
|
On Tue, 22 Jun 2004, Tom Hughes wrote: > > I'm not an expert on this, but I suppose that the binary need to be > > rebuilt as purify does (inserting boundary space between the variables) > > in order to support checking on the stack, and therefore we will not > > see any support for this in Valgrind? > > That's pretty much the current situation, yes. I've experimented with tracking pointer bounds, ie. the range that each pointer should access, but it wasn't terribly successful -- it's a difficult problem at the machine code level. N |
|
From: Paul P. <pa...@pa...> - 2004-06-22 16:53:29
|
>>>>> On Tue, 22 Jun 2004 08:42:24 +0200, Anders Torger <to...@lu...> said:
> If I understand things correctly, Valgrind cannot detect this type of
> problem (at least it did not when I tested it):
Correct.
> I'm not an expert on this, but I suppose that the binary need to be
> rebuilt as purify does (inserting boundary space between the variables)
> in order to support checking on the stack, and therefore we will not
> see any support for this in Valgrind?
Purify does not catch stack overflow errors of this kind either:
**** Purify instrumented a.out (pid 15218) ****
* Program exited with status code 0.
* 0 access errors, 0 total occurrences.
FWIW, here is the output from Insure++ on your test case:
[junk.c:6] **WRITE_BAD_INDEX**
>> a[2] = 1;
Writing array out of range: a[2]
Index used : 2
Valid range: 0 thru 1 (inclusive)
Stack trace where the error occurred:
main() pc: 0x00011064 junk.c, 6
**Memory corrupted. Program may crash!!**
Cheers,
--
Paul Pluzhnikov pa...@pa...
|