This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: out of bound memory check
- From: fche at redhat dot com (Frank Ch. Eigler)
- To: Amol Kumar Lad <amolk at ishoni dot com>
- Cc: gcc at gcc dot gnu dot org, fche at redhat dot com
- Date: 28 Aug 2002 11:11:49 -0400
- Subject: Re: out of bound memory check
- References: <1030545766.2601.65.camel@amol.in.ishoni.com>
Amol Kumar Lad <amolk@ishoni.com> writes:
> Hi,
> Is is possible to catch out of bound memory access in gcc ?
> For example
> int a[100];
> int *p = a;
> *(p + 200) = 5; <-- I need to catch this
>
> Is there any compiler support ?? [...]
One alternative is our so-called mudflap extensions to gcc, similar to
the gcc-checker and bounded-pointer projects. mudflap is being built
up in the tree-ssa branch in the public CVS server, and discussed on
the gcc-patches list.
It runs on this example thusly:
% gcc -fmudflap file.c
% env MUDFLAP_OPTIONS="-verbose-violations -viol-segv" ./a.out
*******
mudflap violation 1 (check): time=1030547370.153324 ptr=bffff950 size=4 pc=08048985 location=`egcslist.c:5 (main)'
./a.out(main+0x1e5) [0x8048985]
/lib/libc.so.6(__libc_start_main+0x93) [0x40072777]
./a.out(__libc_start_main+0x39) [0x80486b1]
Nearby object 1: region is 401B after
mudflap object 08051b80: name=`egcslist.c:3 (main) a'
bounds=[bffff630,bffff7bf] size=400 area=stack access-count=0
alloc time=1030547370.152106 pc=08048821
./a.out(main+0x81) [0x8048821]
/lib/libc.so.6(__libc_start_main+0x93) [0x40072777]
./a.out(__libc_start_main+0x39) [0x80486b1]
number of nearby objects: 1
zsh: segmentation fault MUDFLAP_OPTIONS="-verbose-violations -viol-segv" ./a.out
%
- FChE