bug report - g++ + linuxthreads == seg fault
llewelly@dbritsch.dsl.xmission.com
llewelly@dbritsch.dsl.xmission.com
Tue May 9 19:57:00 GMT 2000
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]
More information about the Gcc-bugs
mailing list