|
From: Paul P. <ppl...@gm...> - 2004-12-10 03:37:48
|
On Wed, 08 Dec 2004 12:21:45 -0800, Steve Fink <sf...@re...> wrote:
>
> "bad stuff happened at byte offset 0 after an allocation of size..."
I don't think any of the alternatives are really better.
Perhaps you can take a leaf from competition :-)
Here is how Insure++ does it (best viewed in fixed font):
$ cat junk.c
#include <stdlib.h>
int main()
{
char *p = malloc(1), *q = p+1;
*q = 'a';
return 0;
}
$ insure gcc -g junk.c && ./a.out
[junk.c:5] **WRITE_OVERFLOW**
>> *q = 'a';
Writing overflows memory: q
bbbbb
| 1 | 1 |
wwwww
Writing (w) : 0x0804a4b9 thru 0x0804a4b9 (1 byte)
To block (b) : 0x0804a4b8 thru 0x0804a4b8 (1 byte)
p, allocated at junk.c, 4
malloc() pc: 0x4004cb27 (interface)
main() pc: 0x08048e2e junk.c, 4
Stack trace where the error occurred:
main() pc: 0x08048f5f junk.c, 5
|