Dear Intel team,
it seems something is fundamentally broken when using allocatables in connection with OpenMP in ifort 18.x.
On top of my earlier bug reports #03202444 and #03214078, here is another related problem:
! compile with "-qopenmp -g" ! and run via valgrind module m implicit none type :: T integer, dimension(:), allocatable :: a end type integer, save :: N = 1 contains subroutine XXX() type(T), dimension(1:N) :: alt ! empty routine end subroutine ! valgrind reports: invalid read in scalable_free (frontend.cpp:2868) on exit subroutine useless_but_necessary() integer :: i !$omp parallel do default(shared) private(i) do i = 1,12 end do !$omp end parallel do end subroutine end module program p use OMP_LIB use m implicit none !$ print *,omp_get_max_threads() call XXX() end
When compiled with -qopenmp and run through valgrind, this gives a shitload of invalid reads in scalable_free (frontend.cpp:2868):
==25020== Invalid read of size 2
==25020== at 0x524BFE5: scalable_free (frontend.cpp:2868)
==25020== by 0x421D29: for_dealloc_allocatable (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x406DE7: for_dealloc_all_nocheck (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x403285: m_mp_xxx_ (p.f90:17)
==25020== by 0x403521: MAIN__ (p.f90:38)
==25020== by 0x402E6D: main (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== Address 0x1ffeffc07a is on thread 1's stack
==25020== 11206 bytes below stack pointer
==25020==
==25020== Invalid read of size 8
==25020== at 0x524BFF7: scalable_free (frontend.cpp:2868)
==25020== by 0x421D29: for_dealloc_allocatable (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x406DE7: for_dealloc_all_nocheck (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x403285: m_mp_xxx_ (p.f90:17)
==25020== by 0x403521: MAIN__ (p.f90:38)
==25020== by 0x402E6D: main (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== Address 0x1ffeffc060 is on thread 1's stack
==25020== 11232 bytes below stack pointer
==25020==
==25020== Invalid read of size 8
==25020== at 0x5249711: rml::internal::Block::freePublicObject(rml::internal::FreeObject*) (frontend.cpp:1372)
==25020== by 0x524C02B: scalable_free (frontend.cpp:2868)
==25020== by 0x421D29: for_dealloc_allocatable (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x406DE7: for_dealloc_all_nocheck (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x403285: m_mp_xxx_ (p.f90:17)
==25020== by 0x403521: MAIN__ (p.f90:38)
==25020== by 0x402E6D: main (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== Address 0x1ffeffc010 is on thread 1's stack
==25020== 11264 bytes below stack pointer
==25020==
==25020== Invalid read of size 8
==25020== at 0x524971B: rml::internal::Block::freePublicObject(rml::internal::FreeObject*) (frontend.cpp:1375)
==25020== by 0x524C02B: scalable_free (frontend.cpp:2868)
==25020== by 0x421D29: for_dealloc_allocatable (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x406DE7: for_dealloc_all_nocheck (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x403285: m_mp_xxx_ (p.f90:17)
==25020== by 0x403521: MAIN__ (p.f90:38)
==25020== by 0x402E6D: main (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== Address 0x1ffeffc010 is on thread 1's stack
==25020== 11264 bytes below stack pointer
==25020==
==25020== Invalid read of size 8
==25020== at 0x5249732: rml::internal::Block::freePublicObject(rml::internal::FreeObject*) (frontend.cpp:1397)
==25020== by 0x524C02B: scalable_free (frontend.cpp:2868)
==25020== by 0x421D29: for_dealloc_allocatable (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x406DE7: for_dealloc_all_nocheck (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x403285: m_mp_xxx_ (p.f90:17)
==25020== by 0x403521: MAIN__ (p.f90:38)
==25020== by 0x402E6D: main (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== Address 0x1ffeffc018 is on thread 1's stack
==25020== 11256 bytes below stack pointer
==25020==
==25020== Invalid read of size 1
==25020== at 0x5249740: rml::internal::Block::freePublicObject(rml::internal::FreeObject*) (frontend.cpp:1400)
==25020== by 0x524C02B: scalable_free (frontend.cpp:2868)
==25020== by 0x421D29: for_dealloc_allocatable (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x406DE7: for_dealloc_all_nocheck (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== by 0x403285: m_mp_xxx_ (p.f90:17)
==25020== by 0x403521: MAIN__ (p.f90:38)
==25020== by 0x402E6D: main (in /home/janus/fort/ifort_bugs/auto_arr_w_alloc_comp/a.out)
==25020== Address 0x10 is not stack'd, malloc'd or (recently) free'd
If you're not so lucky it will segfault on you. I suspect this problem is closely related to #03202444 (which none of your support crew was unable to reproduce so far), because it points to the exact same source line in frontend.cpp (2868). See also the longish thread at https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux...
All of these are extremely serious issues for us. Please fix your compiler!
Best regards,
Janus