This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: bug report - g++ + linuxthreads == seg fault
- To: Brent Verner <brent at linux1 dot org>
- Subject: Re: bug report - g++ + linuxthreads == seg fault
- From: llewelly at dbritsch dot dsl dot xmission dot com
- Date: Tue, 9 May 2000 20:57:29 -0600 (MDT)
- Cc: gcc-bugs at gcc dot gnu dot org
On Tue, 9 May 2000, Brent Verner wrote:
> Forgive me if this report is directed to the wrong place, but I
> can't figure out _where_ the problem lies. If you can help me solve
> this I'd appreciate it greatly :)
>
> cheers.
> brent
>
> ==========================
> the problem:
> ==========================
> brent$ g++ -g -Wall breaks.cc -o breaks -lpthread
> brent$ ./breaks
> calling thread
> running me
> thread joined
> Segmentation fault
I compiled and ran this source on my i686-pc-linux-gnu (redhat 6.1 +
mods), and I got:
{~/cc_exer}g++ -g -Wall -O2 -lpthread c++_threads.cc
{~/cc_exer}./a.out
calling thread
running me
thread joined
{~/cc_exer}gcc --version
2.95.2
binutils: 2.95.0.41
glibc: 2.1.2, with matching linux threads
So upgrading each of the above may help.
gcc is easiest to upgrade, so try upgrading it first (if you do not have
2.95.2 already) (do not forget to pass --enable-threads to configure.)
glibc + linuxthreads is probably the most difficult upgrade, so try that
last.
If you already have the versions above (or newer), you may have an
installation problem.
>
> ==========================
> the source:
> ==========================
> (g++ -v --save-temps -O2 -lpthreads breaks.cc) [attached]
hm. I did not get any attachements.
>
> extern "C" {
> #include <stdio.h>
> #include <pthread.h>
> }
>
> using namespace std;
>
> void* runme(void* arg)
> {
> puts("running me");
> pthread_exit((void*)0);
> }
>
> int
> main(int argc, char** argv)
> {
> pthread_t th;
> puts("calling thread");
> pthread_create( &th, NULL, runme, (void*)0);
> if( pthread_join(th,NULL) ){
> puts("join error");
> }
> puts("thread joined");
> return 0;
> }
>
[snip]