On Tuesday 19 of April 2005 07:36, Xiaoshan Sun wrote: > hi, > the following program has a stack array overran and static arrary overran > . overran of this kind may be a very hard to find bug in a software .so can > gcc provide extra information for other debugging tools to check if an > array is overran ? > program.c: > > int static[5]; > > int main(void) > { > int stack[5]; > > static[5] = 0; > stack [5] = 0; > > return 0; > } > > i have no idea about whom to ask ,gdb or gcc or both ?? e.g. gcc-4.x + mudflap switch. # cat array-overran-checking.c int _static[5]; int main(void) { int _stack[5]; _static[5] = 0; _stack[5] = 0; return 0; } # gcc array-overran-checking.c -O2 -fmudflap -lmudflap # ./a.out ******* mudflap violation 1 (check/write): time=1113950577.801266 ptr=0x80c9b48 size=24 pc=0x4002430a location=`array-overran-checking.c:6 (main)' /usr/lib/libmudflap.so.0(__mf_check+0x44) [0x4002430a] ./a.out(main+0xfe) [0x804884e] /usr/lib/libmudflap.so.0(__wrap_main+0x1d8) [0x40025037] Nearby object 1: checked region begins 0B into and ends 4B after mudflap object 0x80c9d48: name=`array-overran-checking.c:1 _static' bounds=[0x80c9b48,0x80c9b5b] size=20 area=static check=0r/3w liveness=3 alloc time=1113950577.801029 pc=0x40024df3 number of nearby objects: 1 ******* mudflap violation 2 (check/write): time=1113950577.802376 ptr=0xbffff458 size=24 pc=0x4002430a location=`array-overran-checking.c:7 (main)' /usr/lib/libmudflap.so.0(__mf_check+0x44) [0x4002430a] ./a.out(main+0x136) [0x8048886] /usr/lib/libmudflap.so.0(__wrap_main+0x1d8) [0x40025037] Nearby object 1: checked region begins 0B into and ends 4B after mudflap object 0x80cb080: name=`array-overran-checking.c:5 (main) _stack' bounds=[0xbffff458,0xbffff46b] size=20 area=stack check=0r/3w liveness=3 alloc time=1113950577.801240 pc=0x40024df3 number of nearby objects: 1 -- /* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */ #define say(x) lie(x)