------- Comment #2 from jb at gcc dot gnu dot org  2005-12-13 16:13 -------
Unfortunately the goto blas library where I noticed this error is not free
software. But here is a simple testcase that shows the same problem.

File hello.c:

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS     2

void *PrintHello(void *threadid)
{
   printf("\n%d: Hello World!\n", threadid);
   pthread_exit(NULL);
}

void fhellomt_ ()
{
   pthread_t threads[NUM_THREADS];
   pthread_attr_t attr;
   int rc, t, status;
   pthread_attr_init (&attr);
   pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE);
   for(t=0; t<NUM_THREADS; t++){
      printf("Creating thread %d\n", t);
      rc = pthread_create(&threads[t], &attr, PrintHello, (void *)t);
      if (rc){
         printf("ERROR; return code from pthread_create() is %d\n", rc);
         exit(-1);
      }
   }
   pthread_attr_destroy (&attr);
   for(t=0; t<NUM_THREADS; t++)
   {
      rc = pthread_join(threads[t], (void **)&status);
      if (rc)
      {
         printf("ERROR; return code from pthread_join() is %d\n", rc);
         exit(-1);
      }
      printf("Completed join with thread %d status= %d\n",t, status);
   }
}


File fpthello.f90:

! Pthreads hello world
program fpthello
  implicit none
  call fhellomt ()
  print *, 'done'
end program fpthello

Compiled with:

gcc -c hello.c
gfortran fpthello.f90 hello.o -lpthread 

Running it produces:

./a.out
Creating thread 0
Creating thread 1

0: Hello World!
Completed join with thread 0 status= 0

1: Hello World!
Completed join with thread 1 status= 0
 done
zsh: segmentation fault  ./a.out


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377

Reply via email to