This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/5780] New: OpenMP program linked with static libraries gets a runtime memory fault


Simple OpenMP program will not work when compiled with '-static' option

$ cat test.f90
      use omp_lib
      implicit none
      integer, parameter :: NT = 4
      integer :: nThreads(NT)

      print *, 'Call omp_set_dynamic'
!$    call omp_set_dynamic(.false.)
      print *, 'Call omp_set_num_threads'
!$    call omp_set_num_threads(NT)
      print *, 'Now enter the parallel region'

!$omp parallel default(none) shared(nThreads)
      nThreads(omp_get_thread_num()+1) = omp_get_num_threads()
!$omp end parallel

      print*, nThreads

      END
$ gfortran -fopenmp test.f90
$ ./a.out
 Call omp_set_dynamic
 Call omp_set_num_threads
 Now enter the parallel region
           4           4           4           4
$ gfortran -static -fopenmp test.f90
$ ./a.out
Memory fault
$

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30471 offers the following workaround:

$ gfortran -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -fopenmp -static
test.f90
/usr/lib/../lib64/libpthread.a(sem_open.o): In function `sem_open':
(.text+0x46d): warning: the use of `mktemp' is dangerous, better use `mkstemp'
$ ./a.out
 Call omp_set_dynamic
 Call omp_set_num_threads
 Now enter the parallel region
           4           4           4           4
$

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31604#c5 provides analysis on where
the problem is occurring.

-- 
           Summary: OpenMP program linked with static libraries gets a
                    runtime memory fault
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: geir at cray dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=5780

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]