This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: out of bound memory check


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]