Re: Pthread Compile Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm testing an even more simplified test case

int main(int argc, char** argv)
{
 return 0;
}

with

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)


for

1. g++ -g -o t test_pthread.cc -static -fstack-check -lpthread
2. g++ -g -o t test_pthread.cc -fstack-check -lpthread
3. g++ -g -o t test_pthread.cc -static -lpthread
4. g++ -g -o t test_pthread.cc -fstack-check


I get


1. random segfault
2. random segfault
3. OK
4. random segfault

Looks like -fstack-check is to blame on RedHat distributed GCC's.
Googleing a bit showed a thread on a RedHat ML with a discussion about it, and it seems this is broken from RH7's 2.96 to RH9's 3.x.


If you need to use -fstack-check, I suggest that you rebuild your GCC from the sources. BTW, 3.4.0 is due out in a couple of weeks now...

.fw.

Tom Browder wrote:

The following problem occurred for GNU package qdbm:

Given sample program source "test_pthread.cc":

#include <pthread.h>
int
main(int argc, char** argv)
{
 pthread_mutex_t mutex;
 pthread_mutex_init(&mutex, NULL);
 return 0;
}

Compile three ways (using gcc 3.3.2 20031022 (RH Linux 3.3.2-1)):
1. g++ -o t test_pthread.cc -static -fstack-check -lpthread
2. g++ -o t test_pthread.cc -fstack-check -lpthread
3. g++ -o t test_pthread.cc -static -lpthread

Execute each file "t":
1. core dump
2. OK
3. OK

What is being done wrong in compile method 1?

Thanks.

Tom Browder





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux