Re: SegFault with -fstack-check

John <[email protected]> Mon, 7 Jul 2003 06:52:28 +0800 (WST)
Newsgroups gmane.linux.redhat.devel
Message-ID <Pine.LNX.4.44.0307070642390.31845-100000@gw.computerdatasafe.com.au>
On 6 Jul 2003, Sean Bruno wrote:

> I have been troubleshooting an issue with a multi-threaded application
> port from Solaris X86 to Linux.
> 
> It was randomly dumping core on "main" or other random parts of code.
> 
> After hacking on the issue for about a week, I decided to write a little
> hello world program and compile it with the same options as my
> application.  Lo-and-behold it cored in the same manner, randomly and
> confusingly.  
> 
> I then began to pare off flags and includes and libraries until, as if
> by magic, it began to work!
> 
> It turned out that there is an existing issue all the way back to RH 7.2
> with the compile option "-fstack-check"  Here is my sample prog:
> 
> int main()
> {
>                                 printf ("Hello World\n");
>                                 return(0);
> }
> 
> 
> compile with:  gcc -fstack-check -o test
> 
> Run the output program up to 10 times.  It should core dump at least
> once...Is this a bug in the kernel, compiler or standard libs?
 
I'm running Debian/Woody.
summer@Numbat:~/test$ gcc -fstack-check -o test fstack-check.c
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ ./test
Hello World
summer@Numbat:~/test$ gcc --version
2.95.4
summer@Numbat:~/test$
THis is okay too:
summer@Numbat:~/test$ gcc-3.0 --version
3.0.4
summer@Numbat:~/test$
My glibc:
summer@Numbat:~/test$ ldd --version
ldd (GNU libc) 2.2.5
Copyright (C) 2002 Free Software Foundation, Inc.

However, ...
[summer@magpie test]$ gcc -fstack-check -o test fstack-check.c
[summer@magpie test]$ ./test
Hello World
[summer@magpie test]$ ./test
Hello World
[summer@magpie test]$ ./test
Hello World
[summer@magpie test]$ ./test
Hello World
[summer@magpie test]$ ./test
Segmentation fault
[summer@magpie test]$ ./test
Segmentation fault
[summer@magpie test]$ ./test
Segmentation fault
[summer@magpie test]$ ./test
Segmentation fault
[summer@magpie test]$ ./test
Hello World
[summer@magpie test]$ gcc --version
2.96
[summer@magpie test]$ ldd --version
ldd (GNU libc) 2.2.5
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
[summer@magpie test]$
Magpie is running Clark Connect release 0.9.1 which is basically Red Hat
Linux release 7.3 (Valhalla)


-- 
Please, reply only to the list.

Join the "Linux Support by Small Businesses" list at
http://mail.computerdatasafe.com.au/mailman/listinfo/lssb