This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/42865] New: OpenMP threadprivate allocatable saved variable -> seg fault
- From: "longb at cray dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Jan 2010 21:27:19 -0000
- Subject: [Bug fortran/42865] New: OpenMP threadprivate allocatable saved variable -> seg fault
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
For this code:
program F03_2_9_4_1_1a
implicit none
logical :: fail = .false.
call sub1(fail)
if (fail) stop 1
contains
subroutine sub1(fail)
use omp_lib
implicit none
integer, parameter :: NT = 4
logical :: fail
integer :: i
real, allocatable, save :: A(:)
real :: correct_result(NT) ! if (A = correct_result) then test passes
!$omp threadprivate(A)
allocate(A(NT))
call omp_set_num_threads(NT)
call omp_set_dynamic(.false.)
call random_number(correct_result)
A = correct_result
!$omp parallel copyin(A)
! Each thread checks its threadprivate copy of A in a "critical" region to
! attempt to avoid mangling any output.
!$omp critical
do i = 1,NT
! correct_result has "shared" data-sharing attribute by default
if (A(i) /= correct_result(i)) then
print *, 'FAIL: omp_get_thread_num() == ', omp_get_thread_num(), &
' A(', i, ') = ', A(i), '(expected ', correct_result(i), ')'
fail = .true.
end if
end do
!$omp end critical
!$omp end parallel
end subroutine sub1
end program F03_2_9_4_1_1a
>
> gfortran -fopenmp test.f90
> ./a.out
Segmentation fault
>
Information from the OpenMP testers:
! NOTES
! In OpenMP 2.5, ALLOCATABLE arrays were not allowed in a copyin clause.
!
! OpenMP 3.0, p. 102, line 17 states "Each thread's copy of that array must
! be allocated with the same bounds." This seems to imply that the
! programmer must explicitly allocate each thread's copy of the array, but
! p. 101, lines 22-24 states "On entry to any parallel region, each
thread's
! copy of a variable that is affected by a copyin clause for the parallel
! region will acquire the allocation... status of the master thread's copy.
!
! REFERENCES
! OpenMP 3.0, p. 85, lines 12-13 (SAVE attribute needed if not in module
! or main (F08))
! OpenMP 3.0, p. 102, line 17
! OpenMP 3.0, p. 316, lines 18-20
The error appears to be internal to the OpenMP library:
Program terminated with signal 11, Segmentation fault.
#0 0x000000000044f150 in memcpy ()
(gdb) where
#0 0x000000000044f150 in memcpy ()
#1 0x000000000040077e in sub1.1533.omp_fn.0 (.omp_data_i=0x7fffffffbbc0) at
ISU3230.f90:46
#2 0x000000000041eea6 in gomp_thread_start (xdata=<value optimized out>)
at ../../../xt-gcc-4.4.2/libgomp/team.c:115
#3 0x00000000004163d3 in start_thread ()
#4 0x0000000000454eb9 in clone ()
#5 0x0000000000000000 in ?? ()
(gdb) q
The code does execute without error with another compiler.
--
Summary: OpenMP threadprivate allocatable saved variable -> seg
fault
Product: gcc
Version: 4.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: longb at cray dot com
GCC build triplet: x86_64-suse-linux
GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42865