Fortran/OpenMP program crashes with -Mchkptr, am I missing something?

Hi, I am getting a large program running under the nvfortran compiler, and I ran into a confusing crashing bug. Here is a minimum reproducible case:

program crash
   implicit none
   integer, parameter :: dp = selected_real_kind(14,200)
   real(dp), allocatable :: arr(:)

!$omp parallel default(shared) private(arr)
   allocate( arr(50) )
   deallocate( arr )
!$omp end parallel

end program crash

When I compile this program with these arguments, it fails reliably:

nvfortran -mp -Mchkptr crash.f90 -o crash.x
0: Null pointer for arr (crash.f90: 6)
[repeated some number of times]

When I get rid of the -Mchkptr argument, it runs fine.

What am I missing here? Is this a bug in nvfortran, or a bug in my understanding of what is going on?

Probably a compiler issue where the private copies of the array is getting nullified and Mchkptr is picking this up, or it might be checking against the original array. Not sure.

I’ve added TPR #31966 and sent it to engineering for investigation.


FYI, TPR #31966 was fixed in our 22.7 release.

% nvfortran -mp crash.f90 -Mchkptr -V22.7 ; a.out
... cut ...