public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "geir at cray dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug nptl/5780] New: OpenMP program linked with static libraries gets a runtime memory fault
Date: Thu, 21 Feb 2008 00:04:00 -0000	[thread overview]
Message-ID: <20080221000327.5780.geir@cray.com> (raw)

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.


             reply	other threads:[~2008-02-21  0:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-21  0:04 geir at cray dot com [this message]
2008-02-21 14:12 ` [Bug nptl/5780] " carlos at codesourcery dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080221000327.5780.geir@cray.com \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).