-fstack-check

Alexander Kotelnikov sacha@softjoys.ru
Thu Sep 7 08:37:00 GMT 2000


Hi.

I have
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
gcc version 2.95.2 20000220 (Debian GNU/Linux)

When I compile a little program:
int main()
{
  char buf[4000]; // may be you'll need a bit more
  return 0;
}

using 

gcc -fstack-check t.c -o t

and then run ./t

I get Segmentation fault.

gdb says
Program received signal SIGSEGV, Segmentation fault.
0x80483b0 in main () at t.c:3
3         char buf[4000];

(I've recompiled with `-ggdb')

I have not a 4kb stack limit:
$ ulimit -s
8192
i.e. 8Mb

That's all.

PS I found this problem while debugging my c++ multithread program. Now I do 
not use `-fstack-check' to build it, but  info gcc says I should:
`-fstack-check'
     Generate code to verify that you do not go beyond the boundary of
     the stack.  You should specify this flag if you are running in an
     environment with multiple threads, but only rarely need to specify
     it in a single-threaded environment since stack overflow is
     automatically detected on nearly all systems if there is only one

-- 
Alexander Kotelnikov
Saint-Petersburg, Russia


More information about the Gcc-bugs mailing list