NVFortran bug with OpenMP usage of polymorphic pointer argument

I am seeing a segmentation fault with NVFortran when type-bound procedures are called from an OpenMP parallel region using a polymorphic pointer argument. This crash occurs even when a single OpenMP thread is used and has been observed with at least NVFortran 25.11 and 26.1 (Ubuntu 22.04.05).

Below is a minimal example (test_err.F90) that shows the behavior when compiled with nvfortran -O0 -g -mp test_err.F90 -o test_err. A segmentation fault is observed between the two write calls and when run with GDB the SEGFAULT is reported on the call within the parallel section.

module omp_class_err
implicit none

! Simple base class
type, public :: base_class
integer(4) :: val1 = 0
contains
procedure :: ex_method => base_method_impl
end type

! Derived class that overrides method
type, extends(base_class), public :: deriv_class
contains
procedure :: ex_method => deriv_method_impl
end type
contains

! Base implementation of method
subroutine base_method_impl(self)
class(base_class), intent(inout) :: self
self%val1 = 0
end subroutine base_method_impl

! Override implementation of method
subroutine deriv_method_impl(self)
class(deriv_class), intent(inout) :: self
self%val1 = 1
end subroutine deriv_method_impl

! Demonstrate error when calling method in parallel region
subroutine err_case(obj)
class(base_class), pointer, intent(inout) :: obj
call obj%ex_method()
WRITE(*,*)'Serial call successful, val1 = ', obj%val1   ! Succeeds

!$omp parallel shared(obj)
call obj%ex_method()                                    ! SEGFAULT
!$omp end parallel
WRITE(*,*)'Parallel call successful, val1 = ', obj%val1 ! Not reached

end subroutine err_case
end module omp_class_err

! Test program
program test_class_err
use omp_class_err
implicit none
class(base_class), pointer :: obj
allocate(deriv_class::obj)
call err_case(obj)
end program test_class_err

Thanks for the report and welcome.

I was able to recreate the issue here and filed a report, TPR #38266. We’ll have engineering investigate.

-Mat

FYI, TPR#38266 was fixed in our 26.3 release.