This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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 libgomp/60801] New: In gfortran, certain array sizes lead to SEGV within OpenMP PARALLEL DO


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

            Bug ID: 60801
           Summary: In gfortran, certain array sizes lead to SEGV within
                    OpenMP PARALLEL DO
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: genflot at yahoo dot com
                CC: jakub at gcc dot gnu.org

Created attachment 32576
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32576&action=edit
Output of gfortran48 -v -save-temps -Wall -Wextra -fopenmp

The attached Fortran code has 2 simple do-loops.  Both loops are made parallel
by wrapping them in OpenMP PARALLEL DO constructs.  If things worked correctly,
the code would simply print "Hello, world!" 40 times and exit.  However, a
segfault occurs while executing the second do-loop.  What is peculiar is the
the two loops only differ in the size of the local variable named "q".  In the
first loop (which succeeds), q is a 500-by-500 array.  In the second loop
(which fails), it is a 515-by-515 array.  Both loops succeed if the OpenMP
constructs are removed.

The problem occurs in both versions of gfortran that I have installed: 4.8.2
(built from source) and 4.4.7 (pre-compiled from Linux vendor package).  Also,
it occurs on my 4-core laptop and my 12-core desktop (both are x64_64).

In what follows, I provide the code and an example of the error.  The output of
"gfortran -v -save-temps ..." is attached to the message.  If any additional
information is required, I will be happy to provide it.

--------------- Code -------------------

PROGRAM segtst
  INTEGER*4 :: i

!$OMP PARALLEL DO
  DO i=1,20
     CALL func500()   ! Prints message 20 times
  END DO
!$OMP END PARALLEL DO

!$OMP PARALLEL DO
  DO i=1,20
     CALL func515()   ! SIGSEGV in one of the threads
  END DO
!$OMP END PARALLEL DO

END PROGRAM

SUBROUTINE func500()
  INTEGER*4, PARAMETER :: nn=500
  REAL*8 :: q(nn,nn)
  CALL sayhello(nn, q)
END SUBROUTINE func500

SUBROUTINE func515()
  INTEGER*4, PARAMETER :: nn=515
  REAL*8 :: q(nn,nn)
  CALL sayhello(nn, q)
END SUBROUTINE func515

SUBROUTINE sayhello(mm, q)
  REAL*8,    INTENT(IN) :: q(mm,mm)
  INTEGER*4, INTENT(IN) :: mm
  PRINT *, "Hello, world!"
END SUBROUTINE sayhello

------------------ Example of error -----------------
$ gfortran48 -Wall -Wextra -fopenmp segtst.f90
segtst.f90:36.25:

SUBROUTINE sayhello(mm, q)
                         1
Warning: Unused dummy argument 'q' at (1)

$ gdb a.out
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/lewisrd/bugs/a.out...(no debugging symbols
found)...done.
(gdb) r
Starting program: /home/XXX/bugs/a.out 
[Thread debugging using libthread_db enabled]
[New Thread 0x2aaaab64e700 (LWP 3599)]
[New Thread 0x2aaaab84f700 (LWP 3600)]
[New Thread 0x2aaaaba50700 (LWP 3601)]
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x2aaaab64e700 (LWP 3599)]
0x0000000000400a8a in func515_ ()


----------- Compiler output ------------
$ gfortran48 -v -save-temps -Wall -Wextra -fopenmp segtst.f90 2>
compiler_output.txt

The file "compiler_output.txt" is attached.


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